1////////////////////////////////////////////////////////////////////////// 2// // 3// This is a generated file. You can view the original // 4// source in your browser if your browser supports source maps. // 5// Source maps are supported by all recent versions of Chrome, Safari, // 6// and Firefox, and by Internet Explorer 11. // 7// // 8////////////////////////////////////////////////////////////////////////// 9 10 11(function () { 12 13/* Imports */ 14var Meteor = Package.meteor.Meteor; 15var global = Package.meteor.global; 16var meteorEnv = Package.meteor.meteorEnv; 17var meteorInstall = Package.modules.meteorInstall; 18 19var require = meteorInstall({"node_modules":{"meteor":{"interwebs:ui-sortable":{
19"sortable.js":function(require,exports,module){ 20 21/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 22// // 23// packages/interwebs_ui-sortable/sortable.js // 24// // 25/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 // 27/* 28 jQuery UI Sortable plugin wrapper 29 30 @param [ui-sortable] {object} Options to pass to $.fn.sortable() merged onto ui.config 31 */ 32angular.module('ui.sortable', []).value('uiSortableConfig', {}).directive('uiSortable', ['uiSortableConfig', '$timeout', '$log', function (uiSortableConfig, $timeout, $log) { 33 return { 34 require: '?ngModel', 35 scope: { 36 ngModel: '=', 37 uiSortable: '=' 38 }, 39 link: function link(scope, element, attrs, ngModel) { 40 var savedNodes; 41 42 function combineCallbacks(first, second) { 43 if (second && typeof second === 'function') { 44 return function () { 45 first.apply(this, arguments); 46 second.apply(this, arguments); 47 }; 48 } 49 return first; 50 } 51 52 function getSortableWidgetInstance(element) { 53 // this is a fix to support jquery-ui prior to v1.11.x 54 // otherwise we should be using `element.sortable('instance')` 55 var data = element.data('ui-sortable'); 56 if (data && typeof data === 'object' && data.widgetFullName === 'ui-sortable') { 57 return data; 58 } 59 return null; 60 } 61 62 function hasSortingHelper(element, ui) { 63 var helperOption = element.sortable('option', 'helper'); 64 return helperOption === 'clone' || typeof helperOption === 'function' && ui.item.sortable.isCustomHelperUsed(); 65 } 66 67 // thanks jquery-ui 68 function isFloating(item) { 69 return (/left|right/.test(item.css('float')) || /inline|table-cell/.test(item.css('display')) 70 ); 71 } 72 73 function getElementScope(elementScopes, element) { 74 var result = null; 75 for (var i = 0; i < elementScopes.length; i++) { 76 var x = elementScopes[i]; 77 if (x.element[0] === element[0]) { 78 result = x.scope; 79 break; 80 } 81 } 82 return result; 83 } 84 85 function afterStop(e, ui) { 86 ui.item.sortable._destroy(); 87 } 88 89 var opts = {}; 90 91 // directive specific options 92 var directiveOpts = { 93 'ui-floating': undefined 94 }; 95 96 var callbacks = { 97 receive: null, 98 remove: null, 99 start: null, 100 stop: null, 101 update: null 102 }; 103 104 var wrappers = { 105 helper: null 106 }; 107 108 angular.extend(opts, directiveOpts, uiSortableConfig, scope.uiSortable); 109 110 if (!angular.element.fn || !angular.element.fn.jquery) { 111 $log.error('ui.sortable: jQuery should be included before AngularJS!'); 112 return; 113 } 114 115 if (ngModel) { 116 117 // When we add or remove elements, we need the sortable to 'refresh' 118 // so it can find the new/removed elements. 119 scope.$watch('ngModel.length', function () { 120 // Timeout to let ng-repeat modify the DOM 121 $timeout(function () { 122 // ensure that the jquery-ui-sortable widget instance 123 // is still bound to the directive's element 124 if (!!getSortableWidgetInstance(element)) { 125 element.sortable('refresh'); 126 } 127 }, 0, false); 128 }); 129 130 callbacks.start = function (e, ui) { 131 if (opts['ui-floating'] === 'auto') { 132 // since the drag has started, the element will be 133 // absolutely positioned, so we check its siblings 134 var siblings = ui.item.siblings(); 135 var sortableWidgetInstance = getSortableWidgetInstance(angular.element(e.target)); 136 sortableWidgetInstance.floating = isFloating(siblings); 137 } 138 139 // Save the starting position of dragged item 140 ui.item.sortable = { 141 model: ngModel.$modelValue[ui.item.index()], 142 index: ui.item.index(), 143 source: ui.item.parent(), 144 sourceModel: ngModel.$modelValue, 145 cancel: function cancel() { 146 ui.item.sortable._isCanceled = true; 147 }, 148 isCanceled: function isCanceled() { 149 return ui.item.sortable._isCanceled; 150 }, 151 isCustomHelperUsed: function isCustomHelperUsed() { 152 return !!ui.item.sortable._isCustomHelperUsed; 153 }, 154 _isCanceled: false, 155 _isCustomHelperUsed: ui.item.sortable._isCustomHelperUsed, 156 _destroy: function _destroy() { 157 angular.forEach(ui.item.sortable, function (value, key) { 158 ui.item.sortable[key] = undefined; 159 }); 160 } 161 }; 162 }; 163 164 callbacks.activate = function (e, ui) { 165 // We need to make a copy of the current element's contents so 166 // we can restore it after sortable has messed it up. 167 // This is inside activate (instead of start) in order to save 168 // both lists when dragging between connected lists. 169 savedNodes = element.contents(); 170 171 // If this list has a placeholder (the connected lists won't), 172 // don't inlcude it in saved nodes. 173 var placeholder = element.sortable('option', 'placeholder'); 174 175 // placeholder.element will be a function if the placeholder, has 176 // been created (placeholder will be an object). If it hasn't 177 // been created, either placeholder will be false if no 178 // placeholder class was given or placeholder.element will be 179 // undefined if a class was given (placeholder will be a string) 180 if (placeholder && placeholder.element && typeof placeholder.element === 'function') { 181 var phElement = placeholder.element(); 182 // workaround for jquery ui 1.9.x, 183 // not returning jquery collection 184 phElement = angular.element(phElement); 185 186 // exact match with the placeholder's class attribute to handle 187 // the case that multiple connected sortables exist and 188 // the placehoilder option equals the class of sortable items 189 var excludes = element.find('[class="' + phElement.attr('class') + '"]:not([ng-repeat], [data-ng-repeat])'); 190 191 savedNodes = savedNodes.not(excludes); 192 } 193 194 // save the directive's scope so that it is accessible from ui.item.sortable 195 var connectedSortables = ui.item.sortable._connectedSortables || []; 196 197 connectedSortables.push({ 198 element: element, 199 scope: scope 200 }); 201 202 ui.item.sortable._connectedSortables = connectedSortables; 203 }; 204 205 callbacks.update = function (e, ui) { 206 // Save current drop position but only if this is not a second 207 // update that happens when moving between lists because then 208 // the value will be overwritten with the old value 209 if (!ui.item.sortable.received) { 210 ui.item.sortable.dropindex = ui.item.index(); 211 var droptarget = ui.item.parent(); 212 ui.item.sortable.droptarget = droptarget; 213
214 var droptargetScope = getElementScope(ui.item.sortable._connectedSortables, droptarget); 215 ui.item.sortable.droptargetModel = droptargetScope.ngModel; 216 217 // Cancel the sort (let ng-repeat do the sort for us) 218 // Don't cancel if this is the received list because it has 219 // already been canceled in the other list, and trying to cancel 220 // here will mess up the DOM. 221 element.sortable('cancel'); 222 } 223 224 // Put the nodes back exactly the way they started (this is very 225 // important because ng-repeat uses comment elements to delineate 226 // the start and stop of repeat sections and sortable doesn't 227 // respect their order (even if we cancel, the order of the 228 // comments are still messed up). 229 if (hasSortingHelper(element, ui) && !ui.item.sortable.received && element.sortable('option', 'appendTo') === 'parent') { 230 // restore all the savedNodes except .ui-sortable-helper element 231 // (which is placed last). That way it will be garbage collected. 232 savedNodes = savedNodes.not(savedNodes.last()); 233 } 234 savedNodes.appendTo(element); 235 236 // If this is the target connected list then 237 // it's safe to clear the restored nodes since: 238 // update is currently running and 239 // stop is not called for the target list. 240 if (ui.item.sortable.received) { 241 savedNodes = null; 242 } 243 244 // If received is true (an item was dropped in from another list) 245 // then we add the new item to this list otherwise wait until the 246 // stop event where we will know if it was a sort or item was 247 // moved here from another list 248 if (ui.item.sortable.received && !ui.item.sortable.isCanceled()) { 249 scope.$apply(function () { 250 ngModel.$modelValue.splice(ui.item.sortable.dropindex, 0, ui.item.sortable.moved); 251 }); 252 } 253 }; 254 255 callbacks.stop = function (e, ui) { 256 // If the received flag hasn't be set on the item, this is a 257 // normal sort, if dropindex is set, the item was moved, so move 258 // the items in the list. 259 if (!ui.item.sortable.received && 'dropindex' in ui.item.sortable && !ui.item.sortable.isCanceled()) { 260 261 scope.$apply(function () { 262 ngModel.$modelValue.splice(ui.item.sortable.dropindex, 0, ngModel.$modelValue.splice(ui.item.sortable.index, 1)[0]); 263 }); 264 } else { 265 // if the item was not moved, then restore the elements 266 // so that the ngRepeat's comment are correct. 267 if ((!('dropindex' in ui.item.sortable) || ui.item.sortable.isCanceled()) && !hasSortingHelper(element, ui)) { 268 savedNodes.appendTo(element); 269 } 270 } 271 272 // It's now safe to clear the savedNodes 273 // since stop is the last callback. 274 savedNodes = null; 275 }; 276 277 callbacks.receive = function (e, ui) { 278 // An item was dropped here from another list, set a flag on the 279 // item. 280 ui.item.sortable.received = true; 281 }; 282 283 callbacks.remove = function (e, ui) { 284 // Workaround for a problem observed in nested connected lists. 285 // There should be an 'update' event before 'remove' when moving 286 // elements. If the event did not fire, cancel sorting. 287 if (!('dropindex' in ui.item.sortable)) { 288 element.sortable('cancel'); 289 ui.item.sortable.cancel(); 290 } 291 292 // Remove the item from this list's model and copy data into item, 293 // so the next list can retrive it 294 if (!ui.item.sortable.isCanceled()) { 295 scope.$apply(function () { 296 ui.item.sortable.moved = ngModel.$modelValue.splice(ui.item.sortable.index, 1)[0]; 297 }); 298 } 299 }; 300 301 wrappers.helper = function (inner) { 302 if (inner && typeof inner === 'function') { 303 return function (e, item) { 304 var innerResult = inner.apply(this, arguments); 305 item.sortable._isCustomHelperUsed = item !== innerResult; 306 return innerResult; 307 }; 308 } 309 return inner; 310 }; 311 312 scope.$watch('uiSortable', function (newVal /*, oldVal*/) { 313 // ensure that the jquery-ui-sortable widget instance 314 // is still bound to the directive's element 315 var sortableWidgetInstance = getSortableWidgetInstance(element); 316 if (!!sortableWidgetInstance) { 317 angular.forEach(newVal, function (value, key) { 318 // if it's a custom option of the directive, 319 // handle it approprietly 320 if (key in directiveOpts) { 321 if (key === 'ui-floating' && (value === false || value === true)) { 322 sortableWidgetInstance.floating = value; 323 } 324 325 opts[key] = value; 326 return; 327 } 328 329 if (callbacks[key]) { 330 if (key === 'stop') { 331 // call apply after stop 332 value = combineCallbacks(value, function () { 333 scope.$apply(); 334 }); 335 336 value = combineCallbacks(value, afterStop); 337 } 338 // wrap the callback 339 value = combineCallbacks(callbacks[key], value); 340 } else if (wrappers[key]) { 341 value = wrappers[key](value); 342 } 343 344 opts[key] = value; 345 element.sortable('option', key, value); 346 }); 347 } 348 }, true); 349 350 angular.forEach(callbacks, function (value, key) { 351 opts[key] = combineCallbacks(value, opts[key]); 352 if (key === 'stop') { 353 opts[key] = combineCallbacks(opts[key], afterStop); 354 } 355 }); 356 } else { 357 $log.info('ui.sortable: ngModel not provided!', element); 358 } 359 360 // Create sortable 361 element.sortable(opts); 362 } 363 }; 364}]);
365/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 366 367}
367}}}},{ 368 "extensions": [ 369 ".js", 370 ".json" 371 ] 372}); 373 374require("/node_modules/meteor/interwebs:ui-sortable/sortable.js"); 375 376/* Exports */ 377Package._define("interwebs:ui-sortable"); 378 379})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.