rem
stringlengths 0
126k
| add
stringlengths 0
441k
| context
stringlengths 15
136k
|
---|---|---|
this.add = function(signal, callback) { if (!this._pool[signal]) { this._pool[signal] = {} }
|
this.add = function(name, callback) { if (!this._pool[name]) { this._pool[name] = {} this._counts[name] = 0 } this._counts[name]++
|
exports = Class(function(){ this.init = function() { this._pool = {} this._uniqueId = 0 } this.add = function(signal, callback) { if (!this._pool[signal]) { this._pool[signal] = {} } var id = 'p' + this._uniqueId++ this._pool[signal][id] = callback return id } this.remove = function(signal, id) { delete this._pool[signal][id] } this.get = function(signal) { return this._pool[signal] } })
|
this._pool[signal][id] = callback
|
this._pool[name][id] = callback
|
exports = Class(function(){ this.init = function() { this._pool = {} this._uniqueId = 0 } this.add = function(signal, callback) { if (!this._pool[signal]) { this._pool[signal] = {} } var id = 'p' + this._uniqueId++ this._pool[signal][id] = callback return id } this.remove = function(signal, id) { delete this._pool[signal][id] } this.get = function(signal) { return this._pool[signal] } })
|
this.remove = function(signal, id) { delete this._pool[signal][id]
|
this.remove = function(name, id) { delete this._pool[name][id] if (this._counts[name]-- == 0) { delete this._counts[name] }
|
exports = Class(function(){ this.init = function() { this._pool = {} this._uniqueId = 0 } this.add = function(signal, callback) { if (!this._pool[signal]) { this._pool[signal] = {} } var id = 'p' + this._uniqueId++ this._pool[signal][id] = callback return id } this.remove = function(signal, id) { delete this._pool[signal][id] } this.get = function(signal) { return this._pool[signal] } })
|
this.get = function(signal) { return this._pool[signal]
|
this.get = function(name) { return this._pool[name] } this.count = function(name) { return this._counts[name] || 0
|
exports = Class(function(){ this.init = function() { this._pool = {} this._uniqueId = 0 } this.add = function(signal, callback) { if (!this._pool[signal]) { this._pool[signal] = {} } var id = 'p' + this._uniqueId++ this._pool[signal][id] = callback return id } this.remove = function(signal, id) { delete this._pool[signal][id] } this.get = function(signal) { return this._pool[signal] } })
|
var key = shared.keys.getItemPropertyKey(itemId, propName)
|
var key = shared.keys.getItemPropertyKey(itemId, propName), value = properties[propName] if (typeof value == 'boolean') { value = value ? 1 : 0 }
|
fin = Singleton(function(){ // Make sure you have a connection with the server before using fin this.connect = function(callback) { var transport, connectParams = {} switch(jsio.__env.name) { case 'node': transport = 'tcp' connectParams.host = '127.0.0.1' connectParams.port = 5556 connectParams.timeout = 0 break; case 'browser': transport = location.hash.match(/fin-postmessage/) ? 'postmessage' : 'csp' connectParams.url = 'http://' + (document.domain || '127.0.0.1') + ':5555' break; } this._client.connect(transport, connectParams, callback) } /* * Create an item with the given data as properties, * and get notified of the new item id when it's been created */ this.create = function(data, callback) { if (typeof callback != 'function') { throw logger.error('Second argument to fin.create should be a callback') } this.requestResponse('FIN_REQUEST_CREATE_ITEM', { data: data }, callback) } /* * Make a request with an associated requestId, * and call the callback upon response */ this.requestResponse = function(frameName, args, callback) { var requestId = this._scheduleCallback(callback) args._requestId = requestId this.send(frameName, args) } /* * Send a frame to the server */ this.send = function(frameName, args) { this._client.sendFrame(frameName, args) } /* * Register a handler for a type of event from the server */ this.registerEventHandler = function(frameName, callback) { this._client.registerEventHandler(frameName, callback) } /* * Subscribe to an item property, and get notified any time it changes */ this._subIdToChannel = {} this._subscriptionPool = new shared.Pool() this.subscribe = function(itemId, propName, callback) { if (!itemId || !propName || !callback) { logger.error("subscribe requires three arguments", itemId, propName, callback); } var channel = shared.keys.getItemPropertyChannel(itemId, propName) subId = this._subscriptionPool.add(channel, callback) if (this._subscriptionPool.count(channel) == 1) { this.send('FIN_REQUEST_SUBSCRIBE', { id: itemId, prop: propName }) } else if (this._itemMutationCache[channel]) { setTimeout(bind(this, '_handleItemMutation', this._itemMutationCache[channel])) } this._subIdToChannel[subId] = channel return subId } /* * Query fin for items matching a set of properties, and get notified * any time an item enters or leaves the matching set */ this.query = function(query, callback) { if (!query || !callback) { logger.error("query requires two arguments", query, callback); debugger } var queryJSON = JSON.stringify(query), queryChannel = shared.keys.getQueryChannel(queryJSON), subId = this._subscriptionPool.add(queryChannel, callback) if (this._subscriptionPool.count(queryChannel) == 1) { this.send('FIN_REQUEST_QUERY', queryJSON) } else if (this._queryMutationCache[queryChannel]) { setTimeout(bind(this, '_handleQueryMutation', this._queryMutationCache[queryChannel], true)) } return subId } /* * Monitor any changes to a given property. * This should probably not be used except by query robot clients */ this.monitorProperty = function() { throw logger.error("Unimplemented method monitorProperty") } /* * Release a subscription, query, or property monitoring */ this.release = function(subId) { if (typeof subId == 'string') { var channel = this._subIdToChannel[subId] this._subscriptionPool.remove(channel) if (this._subscriptionPool.count() == 0) { this.send('FIN_REQUEST_UNSUBSCRIBE', channel) } delete this._subIdToChannel[subId] } else { // it's a fin template element this._templateFactory.releaseTemplate(subId) } } /* * Mutate a fin item with the given operation */ this.set = function(itemId, properties) { var args = [], props = [] if (arguments.length == 3) { var propName = properties properties = {} properties[propName] = arguments[2] } for (var propName in properties) { var key = shared.keys.getItemPropertyKey(itemId, propName) props.push(propName) args.push(key) args.push(properties[propName]) } this.send('FIN_REQUEST_MUTATE_ITEM', { id: itemId, op: 'mset', props: props, args: args }) } /* * Apply a template to a fin item (or multiple items) */ this.applyTemplate = function(templateString, itemIds) { return this._templateFactory.applyTemplate(templateString, itemIds) } /* * Create a view directly, and get a reference to the javascript object. Make sure you release it correctly! */ this.createView = function(viewName) { var args = Array.prototype.slice.call(arguments, 1) return this._viewFactory.createView(viewName, args) } /* * Register a template view */ this.registerView = function(viewName, viewCtor) { this._viewFactory.registerView(viewName, viewCtor) } var uniqueRequestId = 0 this._scheduleCallback = function(callback) { if (!callback) { return } var requestId = 'r' + uniqueRequestId++ this._requestCallbacks[requestId] = callback return requestId } this._executeCallback = function(requestId, response) { if (!requestId) { return } var callback = this._requestCallbacks[requestId] delete this._requestCallbacks[requestId] callback(response) } this._itemMutationCache = {} this._handleItemMutation = function(mutation) { for (var i=0, propName; propName = mutation.props[i]; i++) { var channel = shared.keys.getItemPropertyChannel(mutation.id, propName) subs = this._subscriptionPool.get(channel) for (var subId in subs) { if (subs[subId]) { subs[subId](mutation, mutation.args[i * 2 + 1]) } } this._itemMutationCache[channel] = mutation } } this._queryMutationCache = {} this._handleQueryMutation = function(mutation, dontCache) { var channel = mutation.id, subs = this._subscriptionPool.get(channel) if (!dontCache) { if (mutation.op == 'sadd') { if (!this._queryMutationCache[channel]) { this._queryMutationCache[channel] = mutation } else { var args = this._queryMutationCache[channel].args for (var i=0, itemId; itemId = mutation.args[i]; i++) { if (args.indexOf(itemId) == -1) { continue } args.push(itemId) } } } else if (mutation.op == 'srem') { var args = this._queryMutationCache[channel].args for (var i=0, itemId; itemId = mutation.args[i]; i++) { args.splice(args.indexOf(itemId), 1) } } } for (var subId in subs) { // TODO store local values and apply mutations other than just "set" subs[subId](mutation, mutation.args[0]) } } // Private method - hook up all internals this.init = function() { this._requestCallbacks = {} this._viewFactory = new client.ViewFactory() this._templateFactory = new client.TemplateFactory(this._viewFactory) this._client = new client.Client() this._client.registerEventHandler('FIN_RESPONSE', bind(this, function(response) { this._executeCallback(response._requestId, response.data) })) this._client.registerEventHandler('FIN_EVENT_ITEM_MUTATED', bind(this, function(mutationJSON) { this._handleItemMutation(JSON.parse(mutationJSON)) })) this._client.registerEventHandler('FIN_EVENT_QUERY_MUTATED', bind(this, function(mutationJSON) { this._handleQueryMutation(JSON.parse(mutationJSON)) })) }})
|
args.push(properties[propName]) } this.send('FIN_REQUEST_MUTATE_ITEM', { id: itemId, op: 'mset', props: props, args: args }) }
|
args.push(JSON.stringify(value)) } this._mutate({ id: itemId, op: 'mset', props: props, args: args }) } this._mutate = function(mutation) { this._handleItemMutation(mutation) this.send('FIN_REQUEST_MUTATE_ITEM', mutation) }
|
fin = Singleton(function(){ // Make sure you have a connection with the server before using fin this.connect = function(callback) { var transport, connectParams = {} switch(jsio.__env.name) { case 'node': transport = 'tcp' connectParams.host = '127.0.0.1' connectParams.port = 5556 connectParams.timeout = 0 break; case 'browser': transport = location.hash.match(/fin-postmessage/) ? 'postmessage' : 'csp' connectParams.url = 'http://' + (document.domain || '127.0.0.1') + ':5555' break; } this._client.connect(transport, connectParams, callback) } /* * Create an item with the given data as properties, * and get notified of the new item id when it's been created */ this.create = function(data, callback) { if (typeof callback != 'function') { throw logger.error('Second argument to fin.create should be a callback') } this.requestResponse('FIN_REQUEST_CREATE_ITEM', { data: data }, callback) } /* * Make a request with an associated requestId, * and call the callback upon response */ this.requestResponse = function(frameName, args, callback) { var requestId = this._scheduleCallback(callback) args._requestId = requestId this.send(frameName, args) } /* * Send a frame to the server */ this.send = function(frameName, args) { this._client.sendFrame(frameName, args) } /* * Register a handler for a type of event from the server */ this.registerEventHandler = function(frameName, callback) { this._client.registerEventHandler(frameName, callback) } /* * Subscribe to an item property, and get notified any time it changes */ this._subIdToChannel = {} this._subscriptionPool = new shared.Pool() this.subscribe = function(itemId, propName, callback) { if (!itemId || !propName || !callback) { logger.error("subscribe requires three arguments", itemId, propName, callback); } var channel = shared.keys.getItemPropertyChannel(itemId, propName) subId = this._subscriptionPool.add(channel, callback) if (this._subscriptionPool.count(channel) == 1) { this.send('FIN_REQUEST_SUBSCRIBE', { id: itemId, prop: propName }) } else if (this._itemMutationCache[channel]) { setTimeout(bind(this, '_handleItemMutation', this._itemMutationCache[channel])) } this._subIdToChannel[subId] = channel return subId } /* * Query fin for items matching a set of properties, and get notified * any time an item enters or leaves the matching set */ this.query = function(query, callback) { if (!query || !callback) { logger.error("query requires two arguments", query, callback); debugger } var queryJSON = JSON.stringify(query), queryChannel = shared.keys.getQueryChannel(queryJSON), subId = this._subscriptionPool.add(queryChannel, callback) if (this._subscriptionPool.count(queryChannel) == 1) { this.send('FIN_REQUEST_QUERY', queryJSON) } else if (this._queryMutationCache[queryChannel]) { setTimeout(bind(this, '_handleQueryMutation', this._queryMutationCache[queryChannel], true)) } return subId } /* * Monitor any changes to a given property. * This should probably not be used except by query robot clients */ this.monitorProperty = function() { throw logger.error("Unimplemented method monitorProperty") } /* * Release a subscription, query, or property monitoring */ this.release = function(subId) { if (typeof subId == 'string') { var channel = this._subIdToChannel[subId] this._subscriptionPool.remove(channel) if (this._subscriptionPool.count() == 0) { this.send('FIN_REQUEST_UNSUBSCRIBE', channel) } delete this._subIdToChannel[subId] } else { // it's a fin template element this._templateFactory.releaseTemplate(subId) } } /* * Mutate a fin item with the given operation */ this.set = function(itemId, properties) { var args = [], props = [] if (arguments.length == 3) { var propName = properties properties = {} properties[propName] = arguments[2] } for (var propName in properties) { var key = shared.keys.getItemPropertyKey(itemId, propName) props.push(propName) args.push(key) args.push(properties[propName]) } this.send('FIN_REQUEST_MUTATE_ITEM', { id: itemId, op: 'mset', props: props, args: args }) } /* * Apply a template to a fin item (or multiple items) */ this.applyTemplate = function(templateString, itemIds) { return this._templateFactory.applyTemplate(templateString, itemIds) } /* * Create a view directly, and get a reference to the javascript object. Make sure you release it correctly! */ this.createView = function(viewName) { var args = Array.prototype.slice.call(arguments, 1) return this._viewFactory.createView(viewName, args) } /* * Register a template view */ this.registerView = function(viewName, viewCtor) { this._viewFactory.registerView(viewName, viewCtor) } var uniqueRequestId = 0 this._scheduleCallback = function(callback) { if (!callback) { return } var requestId = 'r' + uniqueRequestId++ this._requestCallbacks[requestId] = callback return requestId } this._executeCallback = function(requestId, response) { if (!requestId) { return } var callback = this._requestCallbacks[requestId] delete this._requestCallbacks[requestId] callback(response) } this._itemMutationCache = {} this._handleItemMutation = function(mutation) { for (var i=0, propName; propName = mutation.props[i]; i++) { var channel = shared.keys.getItemPropertyChannel(mutation.id, propName) subs = this._subscriptionPool.get(channel) for (var subId in subs) { if (subs[subId]) { subs[subId](mutation, mutation.args[i * 2 + 1]) } } this._itemMutationCache[channel] = mutation } } this._queryMutationCache = {} this._handleQueryMutation = function(mutation, dontCache) { var channel = mutation.id, subs = this._subscriptionPool.get(channel) if (!dontCache) { if (mutation.op == 'sadd') { if (!this._queryMutationCache[channel]) { this._queryMutationCache[channel] = mutation } else { var args = this._queryMutationCache[channel].args for (var i=0, itemId; itemId = mutation.args[i]; i++) { if (args.indexOf(itemId) == -1) { continue } args.push(itemId) } } } else if (mutation.op == 'srem') { var args = this._queryMutationCache[channel].args for (var i=0, itemId; itemId = mutation.args[i]; i++) { args.splice(args.indexOf(itemId), 1) } } } for (var subId in subs) { // TODO store local values and apply mutations other than just "set" subs[subId](mutation, mutation.args[0]) } } // Private method - hook up all internals this.init = function() { this._requestCallbacks = {} this._viewFactory = new client.ViewFactory() this._templateFactory = new client.TemplateFactory(this._viewFactory) this._client = new client.Client() this._client.registerEventHandler('FIN_RESPONSE', bind(this, function(response) { this._executeCallback(response._requestId, response.data) })) this._client.registerEventHandler('FIN_EVENT_ITEM_MUTATED', bind(this, function(mutationJSON) { this._handleItemMutation(JSON.parse(mutationJSON)) })) this._client.registerEventHandler('FIN_EVENT_QUERY_MUTATED', bind(this, function(mutationJSON) { this._handleQueryMutation(JSON.parse(mutationJSON)) })) }})
|
this.focus = function() {
|
this.focusLeftmost = function() {
|
exports = Class(browser.UIComponent, function(supr) { var margin = { top: 10, bottom: 40 }; var padding = 3; var handleWidth = 10; var minHeight = 100; var width = 170; this.init = function() { supr(this, 'init'); this._itemViewClickCallback = bind(this, '_onItemViewClick'); this._labelListPanel = new browser.panels.ListPanel(this, 'Drawer'); } this.createContent = function() { this.addClassName('Drawer'); this._labelListPanel.appendTo(this._element); this._labelListPanel.addClassName('labelListPanel') this._labelListPanel.subscribe('ItemSelected', bind(this, '_onLabelSelected')); var addLabelLink = dom.create({ parent: this._labelListPanel.getElement(), className: 'addLabelLink', html: '+ add label' }); events.add(addLabelLink, 'click', gCreateLabelFn); this.layout(); } this.focus = function() { this._labelListPanel.focus(); } this.focusLabelView = function() { if (this._labelViewPanel) { this._labelViewPanel.focus(); } else { this.focus(); } } this.focusPanel = function() { if (!this._labelViewPanel) { return; } this.addClassName('labelListOpen'); this._labelViewPanel.focus(); } this.removePanel = function() { if (!this._labelViewPanel) { return; } this.removeClassName('labelListOpen'); this._labelViewPanel.unsubscribe('ItemSelected', this._itemViewClickCallback); dom.remove(this._labelViewPanel.getElement()); this._labelViewPanel = null; browser.resizeManager.fireResize(); } this.layout = function() { var size = dimensions.getSize(window); var height = Math.max(minHeight, size.height - margin.top - margin.bottom); var panelWidth = this._labelViewPanel ? 320 : 0; this._labelListPanel.layout({ height: height, width: width, top: margin.top }); if (this._labelViewPanel) { this._labelViewPanel.layout({ width: panelWidth + 2, height: height, top: margin.top, left: width + 6 }); } return { width: width + panelWidth, height: height, top: margin.top }; } this.addLabels = function(labels) { for (var i=0, label; label = labels[i]; i++) { var item = new browser.Label(label); this._labelListPanel.addItem(item); } } this._onLabelSelected = function(label) { if (this._labelViewPanel && this._labelViewPanel.getLabel() == label) { return; } this.removePanel(); gClient.getItemsForLabel(label, bind(this, '_onLabelItemsReceived')); this._labelViewPanel = new browser.panels.ListPanel(this, label); this._labelViewPanel.appendTo(this._element); this._labelViewPanel.addClassName('labelViewPanel'); this._labelViewPanel.subscribe('ItemSelected', this._itemViewClickCallback); this.focusPanel(); browser.resizeManager.fireResize(); } this._onLabelItemsReceived = function(label, items) { for (var i=0, item; item = items[i]; i++) { var itemView = new browser.ItemView(item, item.getType(), 'line'); this._labelViewPanel.addItem(itemView); } } this._onItemViewClick = function(itemView) { gPanelManager.showItem(itemView.getItem()); }})
|
this.focusLabelView = function() {
|
this.focus = function() {
|
exports = Class(browser.UIComponent, function(supr) { var margin = { top: 10, bottom: 40 }; var padding = 3; var handleWidth = 10; var minHeight = 100; var width = 170; this.init = function() { supr(this, 'init'); this._itemViewClickCallback = bind(this, '_onItemViewClick'); this._labelListPanel = new browser.panels.ListPanel(this, 'Drawer'); } this.createContent = function() { this.addClassName('Drawer'); this._labelListPanel.appendTo(this._element); this._labelListPanel.addClassName('labelListPanel') this._labelListPanel.subscribe('ItemSelected', bind(this, '_onLabelSelected')); var addLabelLink = dom.create({ parent: this._labelListPanel.getElement(), className: 'addLabelLink', html: '+ add label' }); events.add(addLabelLink, 'click', gCreateLabelFn); this.layout(); } this.focus = function() { this._labelListPanel.focus(); } this.focusLabelView = function() { if (this._labelViewPanel) { this._labelViewPanel.focus(); } else { this.focus(); } } this.focusPanel = function() { if (!this._labelViewPanel) { return; } this.addClassName('labelListOpen'); this._labelViewPanel.focus(); } this.removePanel = function() { if (!this._labelViewPanel) { return; } this.removeClassName('labelListOpen'); this._labelViewPanel.unsubscribe('ItemSelected', this._itemViewClickCallback); dom.remove(this._labelViewPanel.getElement()); this._labelViewPanel = null; browser.resizeManager.fireResize(); } this.layout = function() { var size = dimensions.getSize(window); var height = Math.max(minHeight, size.height - margin.top - margin.bottom); var panelWidth = this._labelViewPanel ? 320 : 0; this._labelListPanel.layout({ height: height, width: width, top: margin.top }); if (this._labelViewPanel) { this._labelViewPanel.layout({ width: panelWidth + 2, height: height, top: margin.top, left: width + 6 }); } return { width: width + panelWidth, height: height, top: margin.top }; } this.addLabels = function(labels) { for (var i=0, label; label = labels[i]; i++) { var item = new browser.Label(label); this._labelListPanel.addItem(item); } } this._onLabelSelected = function(label) { if (this._labelViewPanel && this._labelViewPanel.getLabel() == label) { return; } this.removePanel(); gClient.getItemsForLabel(label, bind(this, '_onLabelItemsReceived')); this._labelViewPanel = new browser.panels.ListPanel(this, label); this._labelViewPanel.appendTo(this._element); this._labelViewPanel.addClassName('labelViewPanel'); this._labelViewPanel.subscribe('ItemSelected', this._itemViewClickCallback); this.focusPanel(); browser.resizeManager.fireResize(); } this._onLabelItemsReceived = function(label, items) { for (var i=0, item; item = items[i]; i++) { var itemView = new browser.ItemView(item, item.getType(), 'line'); this._labelViewPanel.addItem(itemView); } } this._onItemViewClick = function(itemView) { gPanelManager.showItem(itemView.getItem()); }})
|
this.focus();
|
this._labelListPanel.focus();
|
exports = Class(browser.UIComponent, function(supr) { var margin = { top: 10, bottom: 40 }; var padding = 3; var handleWidth = 10; var minHeight = 100; var width = 170; this.init = function() { supr(this, 'init'); this._itemViewClickCallback = bind(this, '_onItemViewClick'); this._labelListPanel = new browser.panels.ListPanel(this, 'Drawer'); } this.createContent = function() { this.addClassName('Drawer'); this._labelListPanel.appendTo(this._element); this._labelListPanel.addClassName('labelListPanel') this._labelListPanel.subscribe('ItemSelected', bind(this, '_onLabelSelected')); var addLabelLink = dom.create({ parent: this._labelListPanel.getElement(), className: 'addLabelLink', html: '+ add label' }); events.add(addLabelLink, 'click', gCreateLabelFn); this.layout(); } this.focus = function() { this._labelListPanel.focus(); } this.focusLabelView = function() { if (this._labelViewPanel) { this._labelViewPanel.focus(); } else { this.focus(); } } this.focusPanel = function() { if (!this._labelViewPanel) { return; } this.addClassName('labelListOpen'); this._labelViewPanel.focus(); } this.removePanel = function() { if (!this._labelViewPanel) { return; } this.removeClassName('labelListOpen'); this._labelViewPanel.unsubscribe('ItemSelected', this._itemViewClickCallback); dom.remove(this._labelViewPanel.getElement()); this._labelViewPanel = null; browser.resizeManager.fireResize(); } this.layout = function() { var size = dimensions.getSize(window); var height = Math.max(minHeight, size.height - margin.top - margin.bottom); var panelWidth = this._labelViewPanel ? 320 : 0; this._labelListPanel.layout({ height: height, width: width, top: margin.top }); if (this._labelViewPanel) { this._labelViewPanel.layout({ width: panelWidth + 2, height: height, top: margin.top, left: width + 6 }); } return { width: width + panelWidth, height: height, top: margin.top }; } this.addLabels = function(labels) { for (var i=0, label; label = labels[i]; i++) { var item = new browser.Label(label); this._labelListPanel.addItem(item); } } this._onLabelSelected = function(label) { if (this._labelViewPanel && this._labelViewPanel.getLabel() == label) { return; } this.removePanel(); gClient.getItemsForLabel(label, bind(this, '_onLabelItemsReceived')); this._labelViewPanel = new browser.panels.ListPanel(this, label); this._labelViewPanel.appendTo(this._element); this._labelViewPanel.addClassName('labelViewPanel'); this._labelViewPanel.subscribe('ItemSelected', this._itemViewClickCallback); this.focusPanel(); browser.resizeManager.fireResize(); } this._onLabelItemsReceived = function(label, items) { for (var i=0, item; item = items[i]; i++) { var itemView = new browser.ItemView(item, item.getType(), 'line'); this._labelViewPanel.addItem(itemView); } } this._onItemViewClick = function(itemView) { gPanelManager.showItem(itemView.getItem()); }})
|
this.removePanel = function() { if (!this._labelViewPanel) { return; }
|
this.removePanel = function(panel) { if (!panel || panel != this._labelViewPanel) { return; }
|
exports = Class(browser.UIComponent, function(supr) { var margin = { top: 10, bottom: 40 }; var padding = 3; var handleWidth = 10; var minHeight = 100; var width = 170; this.init = function() { supr(this, 'init'); this._itemViewClickCallback = bind(this, '_onItemViewClick'); this._labelListPanel = new browser.panels.ListPanel(this, 'Drawer'); } this.createContent = function() { this.addClassName('Drawer'); this._labelListPanel.appendTo(this._element); this._labelListPanel.addClassName('labelListPanel') this._labelListPanel.subscribe('ItemSelected', bind(this, '_onLabelSelected')); var addLabelLink = dom.create({ parent: this._labelListPanel.getElement(), className: 'addLabelLink', html: '+ add label' }); events.add(addLabelLink, 'click', gCreateLabelFn); this.layout(); } this.focus = function() { this._labelListPanel.focus(); } this.focusLabelView = function() { if (this._labelViewPanel) { this._labelViewPanel.focus(); } else { this.focus(); } } this.focusPanel = function() { if (!this._labelViewPanel) { return; } this.addClassName('labelListOpen'); this._labelViewPanel.focus(); } this.removePanel = function() { if (!this._labelViewPanel) { return; } this.removeClassName('labelListOpen'); this._labelViewPanel.unsubscribe('ItemSelected', this._itemViewClickCallback); dom.remove(this._labelViewPanel.getElement()); this._labelViewPanel = null; browser.resizeManager.fireResize(); } this.layout = function() { var size = dimensions.getSize(window); var height = Math.max(minHeight, size.height - margin.top - margin.bottom); var panelWidth = this._labelViewPanel ? 320 : 0; this._labelListPanel.layout({ height: height, width: width, top: margin.top }); if (this._labelViewPanel) { this._labelViewPanel.layout({ width: panelWidth + 2, height: height, top: margin.top, left: width + 6 }); } return { width: width + panelWidth, height: height, top: margin.top }; } this.addLabels = function(labels) { for (var i=0, label; label = labels[i]; i++) { var item = new browser.Label(label); this._labelListPanel.addItem(item); } } this._onLabelSelected = function(label) { if (this._labelViewPanel && this._labelViewPanel.getLabel() == label) { return; } this.removePanel(); gClient.getItemsForLabel(label, bind(this, '_onLabelItemsReceived')); this._labelViewPanel = new browser.panels.ListPanel(this, label); this._labelViewPanel.appendTo(this._element); this._labelViewPanel.addClassName('labelViewPanel'); this._labelViewPanel.subscribe('ItemSelected', this._itemViewClickCallback); this.focusPanel(); browser.resizeManager.fireResize(); } this._onLabelItemsReceived = function(label, items) { for (var i=0, item; item = items[i]; i++) { var itemView = new browser.ItemView(item, item.getType(), 'line'); this._labelViewPanel.addItem(itemView); } } this._onItemViewClick = function(itemView) { gPanelManager.showItem(itemView.getItem()); }})
|
this.removePanel();
|
this.removePanel(this._labelViewPanel);
|
exports = Class(browser.UIComponent, function(supr) { var margin = { top: 10, bottom: 40 }; var padding = 3; var handleWidth = 10; var minHeight = 100; var width = 170; this.init = function() { supr(this, 'init'); this._itemViewClickCallback = bind(this, '_onItemViewClick'); this._labelListPanel = new browser.panels.ListPanel(this, 'Drawer'); } this.createContent = function() { this.addClassName('Drawer'); this._labelListPanel.appendTo(this._element); this._labelListPanel.addClassName('labelListPanel') this._labelListPanel.subscribe('ItemSelected', bind(this, '_onLabelSelected')); var addLabelLink = dom.create({ parent: this._labelListPanel.getElement(), className: 'addLabelLink', html: '+ add label' }); events.add(addLabelLink, 'click', gCreateLabelFn); this.layout(); } this.focus = function() { this._labelListPanel.focus(); } this.focusLabelView = function() { if (this._labelViewPanel) { this._labelViewPanel.focus(); } else { this.focus(); } } this.focusPanel = function() { if (!this._labelViewPanel) { return; } this.addClassName('labelListOpen'); this._labelViewPanel.focus(); } this.removePanel = function() { if (!this._labelViewPanel) { return; } this.removeClassName('labelListOpen'); this._labelViewPanel.unsubscribe('ItemSelected', this._itemViewClickCallback); dom.remove(this._labelViewPanel.getElement()); this._labelViewPanel = null; browser.resizeManager.fireResize(); } this.layout = function() { var size = dimensions.getSize(window); var height = Math.max(minHeight, size.height - margin.top - margin.bottom); var panelWidth = this._labelViewPanel ? 320 : 0; this._labelListPanel.layout({ height: height, width: width, top: margin.top }); if (this._labelViewPanel) { this._labelViewPanel.layout({ width: panelWidth + 2, height: height, top: margin.top, left: width + 6 }); } return { width: width + panelWidth, height: height, top: margin.top }; } this.addLabels = function(labels) { for (var i=0, label; label = labels[i]; i++) { var item = new browser.Label(label); this._labelListPanel.addItem(item); } } this._onLabelSelected = function(label) { if (this._labelViewPanel && this._labelViewPanel.getLabel() == label) { return; } this.removePanel(); gClient.getItemsForLabel(label, bind(this, '_onLabelItemsReceived')); this._labelViewPanel = new browser.panels.ListPanel(this, label); this._labelViewPanel.appendTo(this._element); this._labelViewPanel.addClassName('labelViewPanel'); this._labelViewPanel.subscribe('ItemSelected', this._itemViewClickCallback); this.focusPanel(); browser.resizeManager.fireResize(); } this._onLabelItemsReceived = function(label, items) { for (var i=0, item; item = items[i]; i++) { var itemView = new browser.ItemView(item, item.getType(), 'line'); this._labelViewPanel.addItem(itemView); } } this._onItemViewClick = function(itemView) { gPanelManager.showItem(itemView.getItem()); }})
|
$j(document).ready(function(){
|
$(document).ready(function(){
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
$j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name');
|
$('[name=filters_open]').find('input').each(function() { var formname = $(this).parent('form').attr('name');
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name');
|
if( $.inArray($(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $(this).attr('name');
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
$j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize();
|
$.each( form_fields, function (index, value) { serialized_form_fields[value] = $('[name=filters_open]').find('[name='+value+']').serialize();
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
begin_form = $j('[name=filters_open]').serialize();
|
begin_form = $('[name=filters_open]').serialize();
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
$j('[:input').live("change", function() { filter_highlight_changes($j(this));
|
$('[:input').live("change", function() { filter_highlight_changes($(this));
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
$j(':checkbox').live("click", function() { filter_highlight_changes($j(this));
|
$(':checkbox').live("click", function() { filter_highlight_changes($(this));
|
$j(document).ready(function(){ var i = 0; $j('[name=filters_open]').find('input').each(function() { var formname = $j(this).parent('form').attr('name'); if( formname != 'list_queries_open' && formname != 'open_queries' && formname != 'save_query' ) { // serialize the field and add it to an array if( $j.inArray($j(this).attr('name'),form_fields) == -1 ) { form_fields[i] = $j(this).attr('name'); i++; } } }); $j.each( form_fields, function (index, value) { serialized_form_fields[value] = $j('[name=filters_open]').find('[name='+value+']').serialize(); }); /* Set up events to modify the form css to show when a stored query has been modified */ begin_form = $j('[name=filters_open]').serialize(); $j('[:input').live("change", function() { filter_highlight_changes($j(this)); }); $j(':checkbox').live("click", function() { filter_highlight_changes($j(this)); });});
|
const currentRevision = 2;
|
const currentRevision = 3;
|
(function() { const currentRevision = 2; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { }, destroy : function TDU_destroy() { }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 if ('_setEffectAllowedForDataTransfer' in tabDNDObserver && tabDNDObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('tabDNDObserver._setEffectAllowedForDataTransfer = '+ tabDNDObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, XPathResult.FIRST_ORDERED_NODE_TYPE ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getDraggedTabs : function TDU_getDraggedTabs(aEvent) { var dt = aEvent.dataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_needsRestore) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.max(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; } }; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
getSelectedTabs : function TDU_getSelectedTabs(aEvent) { var b = this.getTabBrowserFromChild(aEvent.target); var w = b.ownerDocument.defaultView; var isMultipleDragEvent = this.isTabsDragging(aEvent); var selectedTabs; var isMultipleDrag = ( ( isMultipleDragEvent && (selectedTabs = this.getDraggedTabs(aEvent)) && selectedTabs.length ) || ( 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( 'MultipleTabService' in w && w.MultipleTabService.isSelected(aTab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; },
|
(function() { const currentRevision = 2; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { }, destroy : function TDU_destroy() { }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 if ('_setEffectAllowedForDataTransfer' in tabDNDObserver && tabDNDObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('tabDNDObserver._setEffectAllowedForDataTransfer = '+ tabDNDObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, XPathResult.FIRST_ORDERED_NODE_TYPE ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getDraggedTabs : function TDU_getDraggedTabs(aEvent) { var dt = aEvent.dataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_needsRestore) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.max(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; } }; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
|
test_async('should work like regular reduce', function (content, callback) {
|
test_async('should work like regular reduce', function (context, complete) {
|
test_async('should work like regular reduce', function (content, callback) { var list = []; //for (var i = 0; i < 400000; i++) { for (var i = 0; i < 1000; i++) { list.push(i); } //var t = new Date(); var expected = list.reduce(function (p, c) { return p + c; }, 0); //sys.debug(new Date() - t); reduce(list, function (p, c, idx, list, callback) { callback(false, p + c); }, 0, function (error, actual) { //sys.debug(new Date() - t); assertEquals(expected, actual, callback); callback(); } ); });
|
assertEquals(expected, actual, callback); callback();
|
assertEquals(expected, actual, complete); end_async_test(complete);
|
test_async('should work like regular reduce', function (content, callback) { var list = []; //for (var i = 0; i < 400000; i++) { for (var i = 0; i < 1000; i++) { list.push(i); } //var t = new Date(); var expected = list.reduce(function (p, c) { return p + c; }, 0); //sys.debug(new Date() - t); reduce(list, function (p, c, idx, list, callback) { callback(false, p + c); }, 0, function (error, actual) { //sys.debug(new Date() - t); assertEquals(expected, actual, callback); callback(); } ); });
|
promise.addCallback(function(data) {
|
fs.readFile(filename, encoding, function (error, data) { if (error) { status = 404; body = '404' sys.puts("Error loading " + filename); return callback(); }
|
promise.addCallback(function(data) { body = data; headers = [ ['Content-Type', content_type], ['Content-Length', (encoding === 'utf8') ? encodeURIComponent(body).replace(/%../g, 'x').length : body.length ] ]; sys.puts("static file " + filename + " loaded"); callback(); });
|
$('input[type=checkbox]#use_date_filters').click(function() { if (!$(this).is(':checked')) { $('form[name=filters] select[name=start_year]').attr('disabled', 'disabled'); $('form[name=filters] select[name=start_month]').attr('disabled', 'disabled'); $('form[name=filters] select[name=start_day]').attr('disabled', 'disabled'); $('form[name=filters] select[name=end_year]').attr('disabled', 'disabled'); $('form[name=filters] select[name=end_month]').attr('disabled', 'disabled'); $('form[name=filters] select[name=end_day]').attr('disabled', 'disabled'); } else { $('form[name=filters] select[name=start_year]').removeAttr('disabled'); $('form[name=filters] select[name=start_month]').removeAttr('disabled'); $('form[name=filters] select[name=start_day]').removeAttr('disabled'); $('form[name=filters] select[name=end_year]').removeAttr('disabled'); $('form[name=filters] select[name=end_month]').removeAttr('disabled'); $('form[name=filters] select[name=end_day]').removeAttr('disabled'); } });
|
$(document).ready( function() { /* Global Tag change event added only if #tag_select exists */ $('#tag_select').live('change', function() { var selected_tag = $('#tag_select option:selected').text(); tag_string_append( selected_tag ); }); $('.collapse-open').show(); $('.collapse-closed').hide(); $('.collapse-link').click( function(event) { event.preventDefault(); var id = $(this).attr('id'); var t_pos = id.indexOf('_closed_link' ); if( t_pos == -1 ) { t_pos = id.indexOf('_open_link' ); } var t_div = id.substring(0, t_pos ); ToggleDiv( t_div ); }); $('input[type=text].autocomplete').autocomplete({ source: function(request, callback) { var fieldName = $(this).attr('element').attr('id'); var postData = {}; postData['entrypoint']= fieldName + '_get_with_prefix'; postData[fieldName] = request.term; $.getJSON('xmlhttprequest.php', postData, function(data) { var results = []; $.each(data, function(i, value) { var item = {}; item.label = $('<div/>').text(value).html(); item.value = value; results.push(item); }); callback(results); }); } }); $('input.autofocus:first, select.autofocus:first, textarea.autofocus:first').focus(); $('input[type=checkbox].check_all').click(function() { var matchingName = $(this).attr('name').replace(/_all$/, ''); $(this).closest('form').find('input[type=checkbox][name=' + matchingName + '\[\]]').attr('checked', this.checked); }); var stopwatch = { timerID: null, elapsedTime: 0, tick: function() { this.elapsedTime += 1000; var seconds = Math.floor(this.elapsedTime / 1000) % 60; var minutes = Math.floor(this.elapsedTime / 60000) % 60; var hours = Math.floor(this.elapsedTime / 3600000) % 60; if (seconds < 10) { seconds = '0' + seconds; } if (minutes < 10) { minutes = '0' + minutes; } if (hours < 10) { hours = '0' + hours; } $('input[type=text].stopwatch_time').attr('value', hours + ':' + minutes + ':' + seconds); this.start(); }, reset: function() { this.stop(); this.elapsedTime = 0; $('input[type=text].stopwatch_time').attr('value', '00:00:00'); }, start: function() { this.stop(); var self = this; this.timerID = window.setTimeout(function() { self.tick(); }, 1000); }, stop: function() { if (typeof this.timerID == 'number') { window.clearTimeout(this.timerID); delete this.timerID; } } } $('input[type=button].stopwatch_toggle').click(function() { if (stopwatch.elapsedTime == 0) { stopwatch.stop(); stopwatch.start(); $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_stop']); } else if (typeof stopwatch.timerID == 'number') { stopwatch.stop(); $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_start']); } else { stopwatch.start(); $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_stop']); } }); $('input[type=button].stopwatch_reset').click(function() { stopwatch.reset(); $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_start']); }); $('input[type=text].datetime').each(function(index, element) { $(this).after('<input type="image" class="button datetime" id="' + element.id + '_datetime_button' + '" src="' + config['icon_path'] + 'calendar-img.gif" />'); Calendar.setup({ inputField: element.id, timeFormat: 24, showsTime: true, ifFormat: config['calendar_js_date_format'], button: element.id + '_datetime_button' }); }); $('.bug-jump').find('[name=bug_id]').focus( function() { var bug_label = $('.bug-jump-form').find('[name=bug_label]').val(); if( $(this).val() == bug_label ) { $(this).val(''); $(this).removeClass('field-default'); } }); $('.bug-jump').find('[name=bug_id]').blur( function() { var bug_label = $('.bug-jump-form').find('[name=bug_label]').val(); if( $(this).val() == '' ) { $(this).val(bug_label); $(this).addClass('field-default'); } }); $('[name=source_query_id]').change( function() { $(this).parent().submit(); }); $('[name=form_set_project]').children('[name=project_id]').change( function() { $(this).parent().submit(); }); $('[name=form_set_project]').children('.button').hide(); setBugLabel();});
|
|
ANNOS_EXPIRE_POLICIES.forEach(function(policy) { params[policy.bind] = policy.type; params[policy.bind + "_time"] = microNow - policy.time; });
|
XPCOMUtils.defineLazyGetter(this, "_db", function () { let db = Cc["@mozilla.org/browser/nav-history-service;1"]. getService(Ci.nsPIPlacesDatabase). DBConnection; let stmt = db.createAsyncStatement( "CREATE TEMP TABLE expiration_notify ( " + " id INTEGER PRIMARY KEY " + ", v_id INTEGER " + ", p_id INTEGER " + ", url TEXT NOT NULL " + ", visit_date INTEGER " + ", expected_results INTEGER NOT NULL " + ") "); stmt.executeAsync(); stmt.finalize(); return db; });
|
ANNOS_EXPIRE_POLICIES.forEach(function(policy) { params[policy.bind] = policy.type; params[policy.bind + "_time"] = microNow - policy.time; });
|
select.click(function() {
|
select.change(function() {
|
(function($) { /** * This plugin shows and hides elements based on the value of a select box. * If there is only one option, the select box will be hidden and * the single element will be shown. * * @param {Object} custom_settings * An object specifying the elements that are pickable */ $.fn.symphonyPickable = function(custom_settings) { var objects = $(this); var settings = { pickables: '.pickable' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ // Pickables var pickables = $(settings.pickables).addClass('.pickable'); // Process pickers return objects.each(function() { var picker = $(this); var select = picker.find('select'); var options = select.find('option'); // Multiple items if(options.size() > 1) { options.each(function() { pickables.filter('#' + $(this).val()).hide(); }); select.click(function() { pickables.hide().filter('#' + $(this).val()).show(); }).click(); } // Single item else { picker.hide(); pickables.filter('#' + select.val()).removeClass('.pickable'); } }); }})(jQuery.noConflict());
|
}).click();
|
}).change();
|
(function($) { /** * This plugin shows and hides elements based on the value of a select box. * If there is only one option, the select box will be hidden and * the single element will be shown. * * @param {Object} custom_settings * An object specifying the elements that are pickable */ $.fn.symphonyPickable = function(custom_settings) { var objects = $(this); var settings = { pickables: '.pickable' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ // Pickables var pickables = $(settings.pickables).addClass('.pickable'); // Process pickers return objects.each(function() { var picker = $(this); var select = picker.find('select'); var options = select.find('option'); // Multiple items if(options.size() > 1) { options.each(function() { pickables.filter('#' + $(this).val()).hide(); }); select.click(function() { pickables.hide().filter('#' + $(this).val()).show(); }).click(); } // Single item else { picker.hide(); pickables.filter('#' + select.val()).removeClass('.pickable'); } }); }})(jQuery.noConflict());
|
$j(document).ready( function() {
|
$(document).ready( function() {
|
$j(document).ready( function() { /* Global Tag change event added only if #tag_select exists */ $j('#tag_select').live('change', function() { var selected_tag = $j('#tag_select option:selected').text(); tag_string_append( selected_tag ); }); $j('.collapse-open').show(); $j('.collapse-closed').hide(); $j('.collapse-link').click( function(event) { event.preventDefault(); var id = $j(this).attr('id'); var t_pos = id.indexOf('_closed_link' ); if( t_pos == -1 ) { t_pos = id.indexOf('_open_link' ); } var t_div = id.substring(0, t_pos ); ToggleDiv( t_div ); });});
|
$j('#tag_select').live('change', function() { var selected_tag = $j('#tag_select option:selected').text();
|
$('#tag_select').live('change', function() { var selected_tag = $('#tag_select option:selected').text();
|
$j(document).ready( function() { /* Global Tag change event added only if #tag_select exists */ $j('#tag_select').live('change', function() { var selected_tag = $j('#tag_select option:selected').text(); tag_string_append( selected_tag ); }); $j('.collapse-open').show(); $j('.collapse-closed').hide(); $j('.collapse-link').click( function(event) { event.preventDefault(); var id = $j(this).attr('id'); var t_pos = id.indexOf('_closed_link' ); if( t_pos == -1 ) { t_pos = id.indexOf('_open_link' ); } var t_div = id.substring(0, t_pos ); ToggleDiv( t_div ); });});
|
$j('.collapse-open').show(); $j('.collapse-closed').hide(); $j('.collapse-link').click( function(event) {
|
$('.collapse-open').show(); $('.collapse-closed').hide(); $('.collapse-link').click( function(event) {
|
$j(document).ready( function() { /* Global Tag change event added only if #tag_select exists */ $j('#tag_select').live('change', function() { var selected_tag = $j('#tag_select option:selected').text(); tag_string_append( selected_tag ); }); $j('.collapse-open').show(); $j('.collapse-closed').hide(); $j('.collapse-link').click( function(event) { event.preventDefault(); var id = $j(this).attr('id'); var t_pos = id.indexOf('_closed_link' ); if( t_pos == -1 ) { t_pos = id.indexOf('_open_link' ); } var t_div = id.substring(0, t_pos ); ToggleDiv( t_div ); });});
|
var id = $j(this).attr('id');
|
var id = $(this).attr('id');
|
$j(document).ready( function() { /* Global Tag change event added only if #tag_select exists */ $j('#tag_select').live('change', function() { var selected_tag = $j('#tag_select option:selected').text(); tag_string_append( selected_tag ); }); $j('.collapse-open').show(); $j('.collapse-closed').hide(); $j('.collapse-link').click( function(event) { event.preventDefault(); var id = $j(this).attr('id'); var t_pos = id.indexOf('_closed_link' ); if( t_pos == -1 ) { t_pos = id.indexOf('_open_link' ); } var t_div = id.substring(0, t_pos ); ToggleDiv( t_div ); });});
|
$('input[type=text].autocomplete').autocomplete({ source: function(request, callback) { var fieldName = $(this).attr('element').attr('id'); var postData = {}; postData['entrypoint']= fieldName + '_get_with_prefix'; postData[fieldName] = request.term; $.getJSON('xmlhttprequest.php', postData, function(data) { var results = []; $.each(data, function(i, value) { var item = {}; item.label = $('<div/>').text(value).html(); item.value = value; results.push(item); }); callback(results); }); } });
|
$j(document).ready( function() { /* Global Tag change event added only if #tag_select exists */ $j('#tag_select').live('change', function() { var selected_tag = $j('#tag_select option:selected').text(); tag_string_append( selected_tag ); }); $j('.collapse-open').show(); $j('.collapse-closed').hide(); $j('.collapse-link').click( function(event) { event.preventDefault(); var id = $j(this).attr('id'); var t_pos = id.indexOf('_closed_link' ); if( t_pos == -1 ) { t_pos = id.indexOf('_open_link' ); } var t_div = id.substring(0, t_pos ); ToggleDiv( t_div ); });});
|
|
var tree = new Tree.TreePanel({
|
tree = new Tree.TreePanel({
|
Ext.onReady(function(){ // to manage drag & drop var oldPosition = null; var oldNextSibling = null; // shorthand var Tree = Ext.tree; var tree = new Tree.TreePanel({ el:treeCfg.tree_div_id, useArrows:true, autoScroll:true, animate:true, enableDD:treeCfg.enableDD, containerScroll: true, loader: new Tree.TreeLoader({ dataUrl:treeCfg.loader }) }); // set the root node var root = new Tree.AsyncTreeNode({ text: treeCfg.root_name, draggable:false, id:treeCfg.root_id, href:treeCfg.root_href }); tree.setRootNode(root); // render the tree tree.render(); // 20080622 - franciscom var treeState = new TreePanelState(tree,treeCfg.cookiePrefix); treeState.init(); // initialize event handlers // Needed to manage save/restore tree state tree.on('expandnode', treeState.onExpand, treeState); tree.on('collapsenode', treeState.onCollapse, treeState); // // Needed to manage drag and drop back-end actions tree.on('startdrag', function(tree, node, event){ oldPosition = node.parentNode.indexOf(node); oldNextSibling = node.nextSibling; }); tree.on('movenode', function(tree,node,oldParent,newParent,newNodePosition ){ writeNodePositionToDB(newParent,node.id,oldParent.id,newParent.id,newNodePosition); }); // restore last state from tree or to the root node as default treeState.restoreState(tree.root.getPath()); //root.expand(); });
|
var filter = template_defaults.filters[c.name];
|
var filter = context.filters[c.name];
|
var out = this.filter_list.reduce( function (p,c) { var filter = template_defaults.filters[c.name]; var arg; if (c.arg) { arg = c.arg; } else if (c.var_arg) { arg = context.get(c.var_arg); } if ( filter && typeof filter === 'function') { return filter(p, arg, safety); } else { // throw 'Cannot find filter'; sys.debug('Cannot find filter ' + c.name); return p; } }, value);
|
objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() {
|
return objects.delegate(settings.items, 'click.tags', function(event) { var item = $(this), object = item.parent(), input = object.parent().find('label input'), value = input.val(), tag = item.attr('class') || item.text();
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text();
|
if(object.is('.singular')) { input.val(tag); }
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0]
|
else if(object.is('.inline')) { var start = input[0].selectionStart, end = input[0].selectionEnd, position = 0; if(start > 0) { input.val(value.substring(0, start) + tag + value.substring(end, value.length)); position = start + tag.length;
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
input.focus(); if (object.hasClass('singular')) { input.value = tag;
|
else { input.val(value + tag); position = value.length + tag.length;
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd;
|
input[0].selectionStart = position; input[0].selectionEnd = position; }
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length);
|
else { var exp = new RegExp('^' + tag + '$', 'i'), tags = value.split(/,\s*/), removed = false; for(var index in tags) { if(tags[index].match(exp)) { tags.splice(index, 1); removed = true;
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
else { input.value += tag;
|
else if(tags[index] == '') { tags.splice(index, 1);
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length;
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
|
else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false;
|
if(!removed) { tags.push(tag); }
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object;
|
input.val(tags.join(', ')); }
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
return objects;
|
(function($) { /** * This plugin inserts tags from a list into an input field. It offers three modes: * singular - allowing only one tag at a time * multiple - allowing multiple tags, comma separated * inline - which adds tags at the current cursor position * * @param {Object} custom_settings * An object specifying the tag list items */ $.fn.symphonyTags = function(custom_settings) { var objects = this; var settings = { items: 'li' }; $.extend(settings, custom_settings); /*-----------------------------------------------------------------------*/ objects = objects.map(function() { var object = $(this); object.find(settings.items).bind('click', function() { var input = $(this).parent().prevAll('label').find('input')[0]; var tag = this.className || $(this).text(); if(input === undefined) { input = $(this).parent().prevAll('#error').find('label input')[0] } input.focus(); // Singular if (object.hasClass('singular')) { input.value = tag; } // Inline else if (object.hasClass('inline')) { var start = input.selectionStart; var end = input.selectionEnd; if (start >= 0) { input.value = input.value.substring(0, start) + tag + input.value.substring(end, input.value.length); } else { input.value += tag; } input.selectionStart = start + tag.length; input.selectionEnd = start + tag.length; } // Multiple else { var exp = new RegExp('^' + tag + '$', 'i'); var tags = input.value.split(/,\s*/); var removed = false; for (var index in tags) { if (tags[index].match(exp)) { tags.splice(index, 1); removed = true; } else if (tags[index] == '') { tags.splice(index, 1); } } if (!removed) tags.push(tag); input.value = tags.join(', '); } }); return object; }); return objects; };})(jQuery.noConflict());
|
|
text.replaceWhitespace = prefs.getBoolPref("extensions.firebug.fireformat.preview.showWhitespace"); text.wrapPosition = prefs.getIntPref("extensions.firebug.fireformatCssFormatter.wrapSize"); text.tabSize = prefs.getIntPref("extensions.firebug.fireformatCssFormatter.tabSize");
|
text.replaceWhitespace = showWhitespace.value; text.wrapPosition = prefCache.getPref("wrapSize"); text.tabSize = prefCache.getPref("tabSize");
|
(function() { const Cc = Components.classes; const Ci = Components.interfaces; const PrefService = Cc["@mozilla.org/preferences-service;1"]; const prefs = PrefService.getService(Ci.nsIPrefBranch2); const preview = { cssRules: [ { type: CSSRule.CHARSET_RULE, encoding: "encoding" }, { type: CSSRule.IMPORT_RULE, href: "href URL", media: { mediaText: "media text" } }, { type: CSSRule.IMPORT_RULE, href: "href href", media: { mediaText: "media text" } }, { type: CSSRule.MEDIA_RULE, media: [ "screen", "print" ], cssRules: [ { type: CSSRule.STYLE_RULE, selectorText: "selector", style: { cssText: "property: value;" } }, { type: CSSRule.STYLE_RULE, selectorText: "selector2", style: { cssText: "property: value; property: value;" } } ] }, { type: CSSRule.STYLE_RULE, selectorText: ".single", style: { cssText: "" } }, { type: CSSRule.STYLE_RULE, selectorText: ".single[name] > DIV.test + *, .double:focus, .triple#myid", style: { cssText: "background-color : green;background : green brown !important;background : \'green string\';" } } ] }; var formatter = Fireformat.Formatters.getFormatter("com.incaseofstairs.fireformatCSSFormatter"); function getTestBox() { return document.getElementById("cssFormatterTest"); } FireformatOptions.updateCssPreview = function() { setTimeout(function() { var prefCache = new FireformatOptions.OptionsPrefCache( document.getElementById("ffmt_cssFormatPreferences"), "extensions.firebug.fireformatCssFormatter"), text = getTestBox(); text.replaceWhitespace = prefs.getBoolPref("extensions.firebug.fireformat.preview.showWhitespace"); text.wrapPosition = prefs.getIntPref("extensions.firebug.fireformatCssFormatter.wrapSize"); text.tabSize = prefs.getIntPref("extensions.firebug.fireformatCssFormatter.tabSize"); text.value = formatter.format(preview, prefCache); window.sizeToContent(); }, 0); };})();
|
var referenceItemId = sourceItem.getProperty(itemReferencePropertyName);
|
var referenceItemId = sourceItem.getProperty(itemReferencePropertyName, true);
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
forEach(this._proxiedCalls, bind(this, function(proxiedCall){
|
for (var i=0, proxiedCall; proxiedCall = this._proxiedCalls[i]; i++) {
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
}))
|
} this._proxiedCalls = [];
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
this.getProperty = function(propertyName) {
|
this.getProperty = function(propertyName, noDefault) {
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
return 'loading...';
|
return propertyName;
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
var self = this; function createProxiedMethod(context, methodName) {
|
function createProxiedMethod(methodName) {
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
this.subscribe = createProxiedMethod(this, 'subscribe');
|
this.subscribe = createProxiedMethod('subscribe');
|
exports = Class(common.Publisher, function(supr) { this.init = function(sourceItem, referencedItemType, itemReferencePropertyName) { supr(this, 'init'); this._proxiedCalls = []; this._referencedItemType = referencedItemType; var referenceItemId = sourceItem.getProperty(itemReferencePropertyName); if (referenceItemId) { this._referencedItem = common.itemFactory.getItem(referenceItemId); } sourceItem.subscribeToProperty(itemReferencePropertyName, bind(this, '_onReferenceChanged')); } this.getReferencedItem = function() { return this._referencedItem; } this._onReferenceChanged = function(newReferenceItemId) { this._referencedItem = common.itemFactory.getItem(newReferenceItemId); forEach(this._proxiedCalls, bind(this, function(proxiedCall){ var methodName = proxiedCall[0]; var args = proxiedCall[1]; this[methodName].apply(this, args); })) this._publish('ReferenceChanged') } this.getId = function() { return this._referencedItem.getId(); } this.asObject = function() { return this._referencedItem.asObject(); } this.toString = function() { return this._referencedItem.toString(); } this.getType = function() { return this._referencedItemType; } this.getProperty = function(propertyName) { if (this._referencedItem) { return this._referencedItem.getProperty(propertyName); } else { return 'loading...'; } } var self = this; function createProxiedMethod(context, methodName) { return function() { if (!this._referencedItem) { this._proxiedCalls.push([methodName, arguments]); return; } this._referencedItem[methodName].apply(this._referencedItem, arguments); } } this.subscribe = createProxiedMethod(this, 'subscribe'); this.unsubscribe = createProxiedMethod('unsubscribe'); this.mutate = createProxiedMethod('mutate'); this.applyMutation = createProxiedMethod('applyMutation'); this.setSnapshot = createProxiedMethod('setSnapshot'); this.setType = createProxiedMethod('setType'); this.subscribeToProperty = createProxiedMethod('subscribeToProperty');})
|
browser.panelManager.showItem(propertyView.getReferencedItem());
|
gPanelManager.showItem(propertyView.getReferencedItem());
|
exports = Class(browser.panels.Panel, function(supr) { this.init = function() { supr(this, 'init', arguments); this._listComponent = new browser.ListComponent(bind(this, '_onItemSelected')); } this.createContent = function() { supr(this, 'createContent'); this.addClassName('ItemPanel'); this._itemView = new browser.ItemView(this._item, this._item.getType(), 'panel'); this._itemView.appendTo(this._content); forEach(this._itemView.getPropertyViews(), bind(this, function(propertyView) { this._listComponent.addItem(propertyView); if (propertyView instanceof browser.ItemReferenceView) { propertyView.subscribe('Click', bind(this, function() { browser.panelManager.showItem(propertyView.getReferencedItem()); })); } else { propertyView.subscribe('DoubleClick', bind(this, '_makeEditable', propertyView)); } })); if (this.hasFocus()) { this._listComponent.focus(); } } this._makeEditable = function(view) { browser.editable.setValue(this._item.getProperty(view.getPropertyName()) || ''); browser.editable.showAt(view.getElement(), bind(this, '_onMutation', view), bind(this, '_onEditableHide')); } this._onMutation = function(view, mutation, value) { view.setValue(value); // set the value of the element beneath the input early, so that its size updates correctly mutation.property = view.getPropertyName(); this._item.mutate(mutation); } this._onEditableHide = function() { if (!this.hasFocus()) { return; } this._listComponent.focus(); } this.focus = function() { supr(this, 'focus'); this._listComponent.focus(); } this._onItemSelected = function(item) { if (item instanceof common.ItemReference || item instanceof browser.ItemReferenceView) { browser.panelManager.showItem(item.getReferencedItem()); } else { var valueView = this._listComponent.getFocusedItem(); this._makeEditable(valueView); } }})
|
browser.panelManager.showItem(item.getReferencedItem());
|
gPanelManager.showItem(item.getReferencedItem());
|
exports = Class(browser.panels.Panel, function(supr) { this.init = function() { supr(this, 'init', arguments); this._listComponent = new browser.ListComponent(bind(this, '_onItemSelected')); } this.createContent = function() { supr(this, 'createContent'); this.addClassName('ItemPanel'); this._itemView = new browser.ItemView(this._item, this._item.getType(), 'panel'); this._itemView.appendTo(this._content); forEach(this._itemView.getPropertyViews(), bind(this, function(propertyView) { this._listComponent.addItem(propertyView); if (propertyView instanceof browser.ItemReferenceView) { propertyView.subscribe('Click', bind(this, function() { browser.panelManager.showItem(propertyView.getReferencedItem()); })); } else { propertyView.subscribe('DoubleClick', bind(this, '_makeEditable', propertyView)); } })); if (this.hasFocus()) { this._listComponent.focus(); } } this._makeEditable = function(view) { browser.editable.setValue(this._item.getProperty(view.getPropertyName()) || ''); browser.editable.showAt(view.getElement(), bind(this, '_onMutation', view), bind(this, '_onEditableHide')); } this._onMutation = function(view, mutation, value) { view.setValue(value); // set the value of the element beneath the input early, so that its size updates correctly mutation.property = view.getPropertyName(); this._item.mutate(mutation); } this._onEditableHide = function() { if (!this.hasFocus()) { return; } this._listComponent.focus(); } this.focus = function() { supr(this, 'focus'); this._listComponent.focus(); } this._onItemSelected = function(item) { if (item instanceof common.ItemReference || item instanceof browser.ItemReferenceView) { browser.panelManager.showItem(item.getReferencedItem()); } else { var valueView = this._listComponent.getFocusedItem(); this._makeEditable(valueView); } }})
|
if (this._type && this._type != type) { throw new Error("Attempting to set type " + type + "for item that already has type" + this._type); }
|
exports = Class(Publisher, function(supr) { this.init = function(id, properties) { supr(this, 'init'); this._id = id; this._type = null; this._rev = null; this._properties = properties || {}; this._propertySubscriptions = {}; } this.mutate = function(mutation) { mutation._id = this._id; this._publish('Mutating', mutation); } this.applyMutation = function(mutation, silent) { logger.log('apply mutation', mutation._id, mutation.property); var value = this._applyMutationToValue(mutation, this._properties[mutation.property] || ''); this._properties[mutation.property] = value; if (!silent) { logger.log('publish PropertyUpdated', mutation.property, value); this._publish('PropertyUpdated', mutation.property, value); } } this._applyMutationToValue = function(mutation, value) { if (mutation.deletion) { var startDelete = mutation.position; var endDelete = mutation.position + mutation.deletion; value = value.slice(0, startDelete) + value.slice(endDelete); } if (mutation.addition) { value = value.slice(0, mutation.position) + mutation.addition + value.slice(mutation.position); } return value; } this.getId = function() { return this._id; } this.getProperty = function(propertyName) { return this._properties[propertyName] } this.getType = function() { return this._type; } this.setSnapshot = function(snapshot) { this.setType(snapshot.type); this._rev = snapshot._rev; for (var propertyName in snapshot.properties) { var newValue = snapshot.properties[propertyName]; this._properties[propertyName] = newValue; this._publish('PropertyUpdated', propertyName, newValue); var propertySubscribers = this._propertySubscriptions[propertyName]; if (!propertySubscribers) { continue; } for (var i=0, callback; callback = propertySubscribers[i]; i++) { callback(newValue); } } } this.setType = function(type) { if (this._type && this._type != type) { throw new Error("Attempting to set type " + type + "for item that already has type" + this._type); } this._type = type; } this.subscribeToProperty = function(property, callback) { if (!this._propertySubscriptions[property]) { this._propertySubscriptions[property] = []; } this._propertySubscriptions[property].push(callback); } this.asObject = function() { return { _id: this._id, _rev: this._rev, type: this._type, properties: this._properties }; } this.toString = function() { return this._id; }})
|
|
if (JX.Stratcom && JX.Stratcom.ready) {
|
if (JX['Stratcom'] && JX['Stratcom'].ready) {
|
(function() { if (window.JX) { return; } window.JX = {}; window['__DEV__'] = window['__DEV__'] || 0; var loaded = false; var onload = []; var master_event_queue = []; JX.__rawEventQueue = function (what) { what = what || window.event; master_event_queue.push(what); if (JX.Stratcom && JX.Stratcom.ready) { // Empty the queue now so that exceptions don't cause us to repeatedly // try to handle events. var local_queue = master_event_queue; master_event_queue = []; for (var ii = 0; ii < local_queue.length; ++ii) { var evt = local_queue[ii]; // Sometimes IE gives us events which throw when ".type" is accessed; // just ignore them since we can't meaningfully dispatch them. TODO: // figure out where these are coming from. try { var test = evt.type; } catch (x) { continue; } if (!loaded && evt.type == 'domready') { document.body && (document.body.id = null); loaded = true; for (var ii = 0; ii < onload.length; ii++) { onload[ii](); } } JX.Stratcom.dispatch(evt); } } else { var t = what.srcElement || what.target; if (t && (what.type in {click:1, submit:1}) && (' '+t.className+' ').match(/ FI_CAPTURE /)) { what.returnValue = false; what.preventDefault && what.preventDefault(); document.body.id = 'event_capture'; return false; } } } JX.enableDispatch = function(root, event) { if (root.addEventListener) { root.addEventListener(event, JX.__rawEventQueue, true); } else { root.attachEvent('on'+event, JX.__rawEventQueue); } }; var root = document.documentElement; var document_events = [ 'click', 'keypress', 'mousedown', 'mouseover', 'mouseout', 'mouseup', 'keydown', // Opera is multilol: it propagates focus/blur oddly and propagates submit // in a way different from other browsers. !window.opera && 'submit', window.opera && 'focus', window.opera && 'blur' ]; for (var ii = 0; ii < document_events.length; ++ii) { document_events[ii] && JX.enableDispatch(root, document_events[ii]); } // In particular, we're interested in capturing window focus/blur here so // long polls can abort when the window is not focused. var window_events = [ 'unload', 'focus', 'blur' ]; for (var ii = 0; ii < window_events.length; ++ii) { JX.enableDispatch(window, window_events[ii]); } JX.__simulate = function(node, event) { if (root.attachEvent) { var e = {target: node, type: event}; JX.__rawEventQueue(e); if (e.returnValue === false) { return false; } } }; // TODO: Document the gigantic IE mess here with focus/blur. // TODO: beforeactivate/beforedeactivate? // http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html if (!root.addEventListener) { root.onfocusin = JX.__rawEventQueue; root.onfocusout = JX.__rawEventQueue; } root = document; if (root.addEventListener) { if (navigator.userAgent.match(/WebKit/)) { var timeout = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { JX.__rawEventQueue({type: 'domready'}); clearTimeout(timeout); } }, 3); } else { root.addEventListener('DOMContentLoaded', function() { JX.__rawEventQueue({type: 'domready'}); }, true); } } else { var src = 'javascript:void(0)'; var action = 'JX.__rawEventQueue({\'type\':\'domready\'});'; // TODO: this is throwing, do we need it? // 'this.parentNode.removeChild(this);'; document.write( '<script onreadystatechange="'+action+'" defer="defer" src="'+src+'">'+ '<\/s'+'cript\>'); } JX.onload = function(func) { if (loaded) { func(); return; } onload.push(func); }})();
|
JX.Stratcom.dispatch(evt);
|
JX['Stratcom'].dispatch(evt);
|
(function() { if (window.JX) { return; } window.JX = {}; window['__DEV__'] = window['__DEV__'] || 0; var loaded = false; var onload = []; var master_event_queue = []; JX.__rawEventQueue = function (what) { what = what || window.event; master_event_queue.push(what); if (JX.Stratcom && JX.Stratcom.ready) { // Empty the queue now so that exceptions don't cause us to repeatedly // try to handle events. var local_queue = master_event_queue; master_event_queue = []; for (var ii = 0; ii < local_queue.length; ++ii) { var evt = local_queue[ii]; // Sometimes IE gives us events which throw when ".type" is accessed; // just ignore them since we can't meaningfully dispatch them. TODO: // figure out where these are coming from. try { var test = evt.type; } catch (x) { continue; } if (!loaded && evt.type == 'domready') { document.body && (document.body.id = null); loaded = true; for (var ii = 0; ii < onload.length; ii++) { onload[ii](); } } JX.Stratcom.dispatch(evt); } } else { var t = what.srcElement || what.target; if (t && (what.type in {click:1, submit:1}) && (' '+t.className+' ').match(/ FI_CAPTURE /)) { what.returnValue = false; what.preventDefault && what.preventDefault(); document.body.id = 'event_capture'; return false; } } } JX.enableDispatch = function(root, event) { if (root.addEventListener) { root.addEventListener(event, JX.__rawEventQueue, true); } else { root.attachEvent('on'+event, JX.__rawEventQueue); } }; var root = document.documentElement; var document_events = [ 'click', 'keypress', 'mousedown', 'mouseover', 'mouseout', 'mouseup', 'keydown', // Opera is multilol: it propagates focus/blur oddly and propagates submit // in a way different from other browsers. !window.opera && 'submit', window.opera && 'focus', window.opera && 'blur' ]; for (var ii = 0; ii < document_events.length; ++ii) { document_events[ii] && JX.enableDispatch(root, document_events[ii]); } // In particular, we're interested in capturing window focus/blur here so // long polls can abort when the window is not focused. var window_events = [ 'unload', 'focus', 'blur' ]; for (var ii = 0; ii < window_events.length; ++ii) { JX.enableDispatch(window, window_events[ii]); } JX.__simulate = function(node, event) { if (root.attachEvent) { var e = {target: node, type: event}; JX.__rawEventQueue(e); if (e.returnValue === false) { return false; } } }; // TODO: Document the gigantic IE mess here with focus/blur. // TODO: beforeactivate/beforedeactivate? // http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html if (!root.addEventListener) { root.onfocusin = JX.__rawEventQueue; root.onfocusout = JX.__rawEventQueue; } root = document; if (root.addEventListener) { if (navigator.userAgent.match(/WebKit/)) { var timeout = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { JX.__rawEventQueue({type: 'domready'}); clearTimeout(timeout); } }, 3); } else { root.addEventListener('DOMContentLoaded', function() { JX.__rawEventQueue({type: 'domready'}); }, true); } } else { var src = 'javascript:void(0)'; var action = 'JX.__rawEventQueue({\'type\':\'domready\'});'; // TODO: this is throwing, do we need it? // 'this.parentNode.removeChild(this);'; document.write( '<script onreadystatechange="'+action+'" defer="defer" src="'+src+'">'+ '<\/s'+'cript\>'); } JX.onload = function(func) { if (loaded) { func(); return; } onload.push(func); }})();
|
const currentRevision = 5;
|
const currentRevision = 6;
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
window.addEventListener('load', this._delayedInit, false);
|
window.addEventListener('load', this, false);
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit;
|
window.removeEventListener('load', this, false); delete this._delayedInit;
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
tabsDragUtils.initTabDNDObserver(TabDNDObserver);
|
this.initTabDNDObserver(TabDNDObserver);
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
window.removeEventListener('load', this._delayedInit, false);
|
window.removeEventListener('load', this, false);
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
mozTypesAt : function DOMDTProxy_mozTypesAt() {
|
mozTypesAt : function DOMDTProxy_mozTypesAt(aIndex) { if (aIndex >= this._tabs.length) return new StringList([]);
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
if (aIndex >= this._tabs.length) return null;
|
(function() { const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; var loadedRevision = 'tabsDragUtils' in window['piro.sakura.ne.jp'] ? window['piro.sakura.ne.jp'].tabsDragUtils.revision : 0 ; if (loadedRevision && loadedRevision > currentRevision) { return; } if (loadedRevision && 'destroy' in window['piro.sakura.ne.jp'].tabsDragUtils) window['piro.sakura.ne.jp'].tabsDragUtils.destroy(); const Cc = Components.classes; const Ci = Components.interfaces; var tabsDragUtils = { revision : currentRevision, init : function TDU_init() { window.addEventListener('load', this._delayedInit, false); }, _delayedInit : function TDU_delayedInit() { window.removeEventListener('load', arguments.callee, false); delete tabsDragUtils._delayedInit; if ( 'PlacesControllerDragHelper' in window && 'onDrop' in PlacesControllerDragHelper && PlacesControllerDragHelper.onDrop.toSource().indexOf('tabsDragUtils.DOMDataTransferProxy') < 0 ) { eval('PlacesControllerDragHelper.onDrop = '+ PlacesControllerDragHelper.onDrop.toSource().replace( // for Firefox 3.5 or later 'var doCopy =', 'var tabsDataTransferProxy = dt = new window["piro.sakura.ne.jp"].tabsDragUtils.DOMDataTransferProxy(dt, insertionPoint); $&' ).replace( // for Tree Style Tab (save tree structure to bookmarks) 'PlacesUIUtils.ptm.doTransaction(txn);', <![CDATA[ if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.beginAddBookmarksFromTabs(tabsDataTransferProxy._tabs); $& if ('_tabs' in tabsDataTransferProxy && 'TreeStyleTabBookmarksService' in window) TreeStyleTabBookmarksService.endAddBookmarksFromTabs(); ]]> ) ); } // for Tab Mix Plus if ('TabDNDObserver' in window) tabsDragUtils.initTabDNDObserver(TabDNDObserver); }, destroy : function TDU_destroy() { if (this._delayedInit) window.removeEventListener('load', this._delayedInit, false); }, initTabBrowser : function TDU_initTabBrowser(aTabBrowser) { var tabDNDObserver = (aTabBrowser.tabContainer && aTabBrowser.tabContainer.tabbrowser == aTabBrowser) ? aTabBrowser.tabContainer : // Firefox 4.0 or later aTabBrowser ; // Firefox 3.5 - 3.6 this.initTabDNDObserver(tabDNDObserver); }, destroyTabBrowser : function TDU_destroyTabBrowser(aTabBrowser) { }, initTabDNDObserver : function TDU_initTabDNDObserver(aObserver) { if ('_setEffectAllowedForDataTransfer' in aObserver && aObserver._setEffectAllowedForDataTransfer.toSource().indexOf('tabDragUtils') < 0) { eval('aObserver._setEffectAllowedForDataTransfer = '+ aObserver._setEffectAllowedForDataTransfer.toSource().replace( 'dt.mozItemCount > 1', '$& && !window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(arguments[0])' ) ); } }, startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) { var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); if (index < 0) return; var dt = aEvent.dataTransfer; dt.setDragImage(this.createDragFeedbackImage(tabs), 0, 0); tabs.splice(index, 1); tabs.unshift(draggedTab); tabs.forEach(function(aTab, aIndex) { dt.mozSetDataAt(TAB_DROP_TYPE, aTab, aIndex); dt.mozSetDataAt('text/x-moz-text-internal', this.getCurrentURIOfTab(aTab), aIndex); }, this); // On Firefox 3.6 or older versions on Windows, drag feedback // image isn't shown if there are multiple drag data... if (tabs.length <= 1 || 'mozSourceNode' in dt || navigator.platform.toLowerCase().indexOf('win') < 0) dt.mozCursor = 'default'; aEvent.stopPropagation(); }, createDragFeedbackImage : function TDU_createDragFeedbackImage(aTabs) { var previews = aTabs.map(function(aTab) { return tabPreviews.capture(aTab, false); }, this); var offset = 16; var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); canvas.width = previews[0].width + (offset * aTabs.length); canvas.height = previews[0].height + (offset * aTabs.length); var ctx = canvas.getContext('2d'); ctx.save(); try { ctx.clearRect(0, 0, canvas.width, canvas.height); previews.forEach(function(aPreview, aIndex) { ctx.drawImage(aPreview, 0, 0); ctx.translate(offset, offset); ctx.globalAlpha = 1 / (aIndex+1); }, this); } catch(e) { } ctx.restore(); return canvas; }, getTabFromEvent : function TDU_getTabFromEvent(aEvent, aReallyOnTab) { var tab = (aEvent.originalTarget || aEvent.target).ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tab"]', aEvent.originalTarget || aEvent.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; if (tab || aReallyOnTab) return tab; var b = this.getTabBrowserFromChild(aEvent.originalTarget); if (b && 'treeStyleTab' in b && 'getTabFromTabbarEvent' in b.treeStyleTab) { // Tree Style Tab return b.treeStyleTab.getTabFromTabbarEvent(aEvent); } return null; }, getTabBrowserFromChild : function TDU_getTabBrowserFromChild(aTabBrowserChild) { if (!aTabBrowserChild) return null; if (aTabBrowserChild.localName == 'tabbrowser') // itself return aTabBrowserChild; if (aTabBrowserChild.tabbrowser) // tabs, Firefox 4.0 or later return aTabBrowserChild.tabbrowser; if (aTabBrowserChild.id == 'TabsToolbar') // tabs toolbar, Firefox 4.0 or later return aTabBrowserChild.getElementsByTagName('tabs')[0].tabbrowser; var b = aTabBrowserChild.ownerDocument.evaluate( 'ancestor-or-self::*[local-name()="tabbrowser"] | '+ 'ancestor-or-self::*[local-name()="tabs" and @tabbrowser]', aTabBrowserChild, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; return (b && b.tabbrowser) || b; }, isTabsDragging : function TDU_isTabsDragging(aEvent) { var dt = aEvent.dataTransfer; if (dt.mozItemCount < 1) return false; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { if (!dt.mozTypesAt(i).contains(TAB_DROP_TYPE)) return false; } return true; }, getSelectedTabs : function TDU_getSelectedTabs(aEventOrTabBrowser) { var event = aEventOrTabBrowser instanceof Components.interfaces.nsIDOMEvent ? aEventOrTabBrowser : null ; var b = this.getTabBrowserFromChild(event ? event.target : aEventOrTabBrowser ); var w = b.ownerDocument.defaultView; var tab = event && this.getTabFromEvent(event); var selectedTabs; var isMultipleDrag = ( ( this.isTabsDragging(event) && (selectedTabs = this.getDraggedTabs(event)) && selectedTabs.length ) || ( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510) 'visibleTabs' in b && (selectedTabs = b.visibleTabs.filter(function(aTab) { return aTab.multiselected; })) && selectedTabs.length ) || ( // Tab Utilities 'selectedTabs' in b && (selectedTabs = b.selectedTabs) && selectedTabs.length ) || ( // Multiple Tab Handler tab && 'MultipleTabService' in w && w.MultipleTabService.isSelected(tab) && MultipleTabService.allowMoveMultipleTabs && (selectedTabs = w.MultipleTabService.getSelectedTabs(b)) && selectedTabs.length ) ); return isMultipleDrag ? selectedTabs : [] ; }, getDraggedTabs : function TDU_getDraggedTabs(aEventOrDataTransfer) { var dt = aEventOrDataTransfer.dataTransfer || aEventOrDataTransfer; var tabs = []; if (dt.mozItemCount < 1 || !dt.mozTypesAt(0).contains(TAB_DROP_TYPE)) return tabs; for (let i = 0, maxi = dt.mozItemCount; i < maxi; i++) { tabs.push(dt.mozGetDataAt(TAB_DROP_TYPE, i)); } return tabs.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); }, getCurrentURIOfTab : function TDU_getCurrentURIOfTab(aTab) { // Firefox 4.0- if (aTab.linkedBrowser.__SS_restoreState == 1) { let data = aTab.linkedBrowser.__SS_data; let entry = data.entries[Math.min(data.index, data.entries.length-1)]; return entry.url; } return aTab.linkedBrowser.currentURI.spec; }, // for drop on bookmarks tree willBeInsertedBeforeExistingNode : function TDU_willBeInsertedBeforeExistingNode(aInsertionPoint) { // drop on folder in the bookmarks menu if (aInsertionPoint.dropNearItemId === void(0)) return false; // drop on folder in the places organizer if (aInsertionPoint._index < 0 && aInsertionPoint.dropNearItemId < 0) return false; return true; } }; function DOMDataTransferProxy(aDataTransfer, aInsertionPoint) { // Don't proxy it because it is not a drag of tabs. if (!aDataTransfer.mozTypesAt(0).contains(TAB_DROP_TYPE)) return aDataTransfer; var tabs = tabsDragUtils.getDraggedTabs(aDataTransfer); // Don't proxy it because there is no selection. if (tabs.length < 2) return aDataTransfer; this._source = aDataTransfer; this._tabs = tabs; if (tabsDragUtils.willBeInsertedBeforeExistingNode(aInsertionPoint)) this._tabs.reverse(); } DOMDataTransferProxy.prototype = { _apply : function DOMDTProxy__apply(aMethod, aArguments) { return this._source[aMethod].apply(this._source, aArguments); }, // nsIDOMDataTransfer get dropEffect() { return this._source.dropEffect; }, set dropEffect(aValue) { return this._source.dropEffect = aValue; }, get effectAllowed() { return this._source.effectAllowed; }, set effectAllowed(aValue) { return this._source.effectAllowed = aValue; }, get files() { return this._source.files; }, get types() { return this._source.types; }, clearData : function DOMDTProxy_clearData() { return this._apply('clearData', arguments); }, setData : function DOMDTProxy_setData() { return this._apply('setData', arguments); }, getData : function DOMDTProxy_getData() { return this._apply('getData', arguments); }, setDragImage : function DOMDTProxy_setDragImage() { return this._apply('setDragImage', arguments); }, addElement : function DOMDTProxy_addElement() { return this._apply('addElement', arguments); }, // nsIDOMNSDataTransfer get mozItemCount() { return this._tabs.length; }, get mozCursor() { return this._source.mozCursor; }, set mozCursor(aValue) { return this._source.mozCursor = aValue; }, mozTypesAt : function DOMDTProxy_mozTypesAt() { // return this._apply('mozTypesAt', [0]); // I return "text/x-moz-url" as a first type, to override behavior for "to-be-restored" tabs. return new StringList(['text/x-moz-url', TAB_DROP_TYPE, 'text/x-moz-text-internal']); }, mozClearDataAt : function DOMDTProxy_mozClearDataAt() { this._tabs = []; return this._apply('mozClearDataAt', [0]); }, mozSetDataAt : function DOMDTProxy_mozSetDataAt(aFormat, aData, aIndex) { this._tabs = []; return this._apply('mozSetDataAt', [aFormat, aData, 0]); }, mozGetDataAt : function DOMDTProxy_mozGetDataAt(aFormat, aIndex) { var tab = this._tabs[aIndex]; switch (aFormat) { case TAB_DROP_TYPE: return tab; case 'text/x-moz-url': return (tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank') + '\n' + tab.label; case 'text/x-moz-text-internal': return tabsDragUtils.getCurrentURIOfTab(tab) || 'about:blank'; } return this._apply('mozGetDataAt', [aFormat, 0]); }, get mozUserCancelled() { return this._source.mozUserCancelled; } }; function StringList(aTypes) { return { __proto__ : aTypes, item : function(aIndex) { return this[aIndex]; }, contains : function(aType) { return this.indexOf(aType) > -1; } }; } tabsDragUtils.DOMDataTransferProxy = DOMDataTransferProxy; tabsDragUtils.StringList = StringList; window['piro.sakura.ne.jp'].tabsDragUtils = tabsDragUtils; tabsDragUtils.init();})();
|
|
this.unsubscribeFromItemSetMutations = function(itemSetId, subId) { this._itemSetSubscriberPool.remove(itemSetId, subId) }
|
exports = Class(Server, function(supr) { this.init = function(itemStore, itemSetStore) { supr(this, 'init', [server.Connection]) this._uniqueId = 0 this._itemStore = itemStore this._itemFactory = new common.ItemFactory(itemStore) this._itemSetFactory = new common.ItemSetFactory(this._itemFactory, itemSetStore) this._databaseScheduledWrites = {} this._itemSubscriberPool = new common.SubscriptionPool() this._itemSetSubscriberPool = new common.SubscriptionPool() } this.exists = function(itemId, callback) { this._itemStore.exists(itemId, callback) } this.createItem = function(itemData, callback) { this._itemStore.storeItemData(itemData, bind(this, function(err, result) { if (err) { throw err } itemData._id = result.id itemData._rev = result.rev var item = this._itemFactory.getItem(itemData) callback(item) })); } this.subscribeToItemMutations = function(itemId, subCallback, snapshotCallback) { var subId = this._itemSubscriberPool.add(itemId, subCallback) this._getItemSnapshot(itemId, snapshotCallback) return subId } this.subscribeToItemSetMutations = function(id, subCallback, snapshotCallback) { var isNew = !this._itemSetFactory.hasItemSet(id) var itemSet = this._itemSetFactory.getItemSet(id) if (isNew) { itemSet.subscribe('Mutated', bind(this, '_onItemSetMutated')) this._itemStore.getAllItems(bind(this, function(properties) { itemSet.handleItemUpdate(properties) })) } var subId = this._itemSetSubscriberPool.add(id, subCallback) itemSet.getItems(function(itemIds){ var snapshot = { _id: id, items: itemIds } snapshotCallback(snapshot) }) return subId } this._onItemSetMutated = function(mutation) { var subs = this._itemSetSubscriberPool.get(mutation._id) this._executeMutationSubs(subs, mutation) } this.handleMutation = function(mutation) { this._itemFactory.handleMutation(mutation) var subs = this._itemSubscriberPool.get(mutation._id) this._executeMutationSubs(subs, mutation) } this._executeMutationSubs = function(subs, mutation) { for (var key in subs) { try { subs[key](mutation) } catch (e) { logger.error('Error when handling mutation', JSON.stringify(e)) } } } this.unsubscribeFromItemMutations = function(itemId, subId) { this._itemSubscriberPool.remove(itemId, subId) } this._getItemSnapshot = function(id, callback) { if (this._itemFactory.hasItem(id)) { var item = this._itemFactory.getItem(id) logger.log('retrieved item from memory', id) logger.debug('item data from memory', JSON.stringify(item.getData())) callback(item.getData()) } else { this._itemStore.getItemData(id, bind(this, function(err, data) { if (err) { logger.warn("Could not retrieve item from db", id, err) return } logger.log('retrieved item from database', id) logger.debug('item data from database', JSON.stringify(data)) var item = this._itemFactory.getItem(data._id) item.setSnapshot(data, true) callback(item.getData()) })) } }})
|
|
browser.panelManager.showItem(itemView.getItem());
|
gPanelManager.showItem(itemView.getItem());
|
exports = Class(browser.UIComponent, function(supr) { var margin = { top: 10, bottom: 40 }; var padding = 3; var handleWidth = 10; var minHeight = 100; var width = 170; var marginLeft = 10; this.init = function() { supr(this, 'init'); this._itemViewClickCallback = bind(this, '_onItemViewClick'); this._labelListPanel = new browser.panels.ListPanel(this, 'Drawer'); this._labelListPanel._contentMargin = 0; } this.createContent = function() { this.addClassName('Drawer'); this._labelListPanel.appendTo(this._element); this._labelListPanel.addClassName('labelListPanel') this._labelListPanel.subscribe('ItemSelected', bind(this, '_onLabelSelected')); var addLabelLink = dom.create({ parent: this._labelListPanel.getElement(), className: 'addLabelLink', html: '+ add label' }); events.add(addLabelLink, 'click', gCreateLabelFn); this.layout(); } this.focusLeftmost = function() { this._labelListPanel.focus(); } this.focus = function() { if (this._labelViewPanel) { this._labelViewPanel.focus(); } else { this._labelListPanel.focus(); } } this.focusPanel = function() { if (!this._labelViewPanel) { return; } this.addClassName('labelListOpen'); this._labelViewPanel.focus(); } this.removePanel = function(panel) { if (!panel || panel != this._labelViewPanel) { return; } this.removeClassName('labelListOpen'); this._labelViewPanel.unsubscribe('ItemSelected', this._itemViewClickCallback); dom.remove(this._labelViewPanel.getElement()); this._labelViewPanel = null; browser.resizeManager.fireResize(); this.focus(); } this.layout = function() { var size = dimensions.getSize(window); var height = Math.max(minHeight, size.height - margin.top - margin.bottom); var panelWidth = this._labelViewPanel ? 320 : 0; this._labelListPanel.layout({ height: height, width: width, top: margin.top, left: marginLeft }); if (this._labelViewPanel) { this._labelViewPanel.layout({ width: panelWidth + 2, height: height, top: margin.top, left: width + marginLeft + 6 }); } return { width: width + panelWidth + marginLeft, height: height, top: margin.top }; } this.addLabels = function(labels) { for (var i=0, label; label = labels[i]; i++) { var item = new browser.Label(label); this._labelListPanel.addItem(item); } } this._onLabelSelected = function(label) { if (this._labelViewPanel && this._labelViewPanel.getLabel() == label) { return; } this.removePanel(this._labelViewPanel); gClient.getItemsForLabel(label, bind(this, '_onLabelItemsReceived')); this._labelViewPanel = new browser.panels.ListPanel(this, label); this._labelViewPanel.appendTo(this._element); this._labelViewPanel.addClassName('labelViewPanel'); this._labelViewPanel.subscribe('ItemSelected', this._itemViewClickCallback); this.focusPanel(); browser.resizeManager.fireResize(); } this._onLabelItemsReceived = function(label, items) { for (var i=0, item; item = items[i]; i++) { var itemView = new browser.ItemView(item, item.getType(), 'line'); this._labelViewPanel.addItem(itemView); } } this._onItemViewClick = function(itemView) { browser.panelManager.showItem(itemView.getItem()); }})
|
+ " div:after {\n" + " content: "test";\n" + " }\n" + " </HTML:style>\n" + " <HTML:style type=\"text/css\">\n" + " <![CDATA[\n" + " div:after {\n" + " content: \"test\";\n" + " }\n" + " ]]>\n"
|
FBTestFirebug.openNewTab(urlBase + "formatter/htmlFormatter/xhtml_index.xhtml", function(win) { var Format = {}; Components.utils.import("resource://fireformat/formatters.jsm", Format); var doc = win.document; var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\" [\n" + " <!ENTITY foo \"food\">\n" + " <!ENTITY bar \"bar\">\n" + " <!ENTITY bar \"bar2\">\n" + " <!ENTITY % baz \"baz\">\n" + "]>\n" + "<?xslt-param?>\n" + "<?xslt-param name=\"color\"\n" + " value=\"blue\"\n" + "?>\n" + "<HTML:html xmlns:HTML=\"http://www.w3.org/1999/xhtml\">\n" + "<HTML:head>\n" + " <HTML:meta content=\"text/xml; charset=utf-8\" http-equiv=\"Content-Type\" />\n" + " <HTML:title>Firediff: HTML Formatter Test</HTML:title>\n" + " <HTML:link href=\"cssSource.css\" rel=\"stylesheet\" type=\"text/css\" />\n" + " <HTML:style type=\"text/css\">\n" + " p {\n" + " background-color: green;\n" + " }\n" + " div {\n" + " background-color: red;\n" + " }\n" + " p {\n" + " margin: 100;\n" + " }\n" + " </HTML:style>\n" + "</HTML:head>\n" + "<HTML:body>\n" + " <!-- \n" + " Comments!\n" + " -->\n" + "\n" + " <![CDATA[CDATA=\"GOOD & STUFF <>\"]]>\n" + "\n" + " <HTML:div id=\"elementValue\" class=\"Value1 & <\" align=\"left\" dir=\"ltr\">\n" + " <HTML:p>Nested Element</HTML:p>\n" + " Escaping & entities.\n" + " <HTML:br />\n" + " <HTML:input type=\"submit\" />\n" + " </HTML:div>\n" + "</HTML:body>\n" + "</HTML:html>"; var formatter = Format.Formatters.getFormatter("com.incaseofstairs.fireformatHTMLFormatter"), text = formatter.format(doc); FBTest.compare(expected, text, "Formatter value"); FBTestFirebug.testDone(); });
|
|
$(document).ready(function() { $('ul.nice-menu').superfish({ hoverClass: 'over', autoArrows: false, dropShadows: false, delay: Drupal.settings.nice_menus_options.delay, speed: Drupal.settings.nice_menus_options.speed }).find('ul').bgIframe({opacity:false}); $('ul.nice-menu ul').css('display', 'none'); });
|
(function ($) { $(document).ready(function() { $('ul.nice-menu').superfish({ hoverClass: 'over', autoArrows: false, dropShadows: false, delay: Drupal.settings.nice_menus_options.delay, speed: Drupal.settings.nice_menus_options.speed }).find('ul').bgIframe({opacity:false}); $('ul.nice-menu ul').css('display', 'none'); }); })(jQuery);
|
$(document).ready(function() { $('ul.nice-menu').superfish({ // Apply a generic hover class. hoverClass: 'over', // Disable generation of arrow mark-up. autoArrows: false, // Disable drop shadows. dropShadows: false, // Mouse delay. delay: Drupal.settings.nice_menus_options.delay, // Animation speed. speed: Drupal.settings.nice_menus_options.speed // Add in Brandon Aaron’s bgIframe plugin for IE select issues. // http://plugins.jquery.com/node/46/release }).find('ul').bgIframe({opacity:false}); $('ul.nice-menu ul').css('display', 'none');});
|
FireformatOptions.updatePreview = function() {
|
FireformatOptions.updateCssPreview = function() {
|
(function() { const Cc = Components.classes; const Ci = Components.interfaces; const PrefService = Cc["@mozilla.org/preferences-service;1"]; const prefs = PrefService.getService(Ci.nsIPrefBranch2); const preview = { cssRules: [ { type: CSSRule.CHARSET_RULE, encoding: "encoding" }, { type: CSSRule.IMPORT_RULE, href: "href URL", media: { mediaText: "media text" } }, { type: CSSRule.IMPORT_RULE, href: "href href", media: { mediaText: "media text" } }, { type: CSSRule.MEDIA_RULE, media: [ "screen", "print" ], cssRules: [ { type: CSSRule.STYLE_RULE, selectorText: "selector", style: { cssText: "property: value;" } }, { type: CSSRule.STYLE_RULE, selectorText: "selector2", style: { cssText: "property: value; property: value;" } } ] }, { type: CSSRule.STYLE_RULE, selectorText: ".single", style: { cssText: "" } }, { type: CSSRule.STYLE_RULE, selectorText: ".single[name] > DIV.test + *, .double:focus, .triple#myid", style: { cssText: "background-color : green;background : green brown !important;background : \'green string\';" } } ] }; var formatter = Fireformat.Formatters.getFormatter("com.incaseofstairs.fireformatCSSFormatter"); function getTestBox() { return document.getElementById("cssFormatterTest"); } FireformatOptions.updatePreview = function() { setTimeout(function() { // Create helper root element (for the case where there is no signle root). var text = getTestBox(); text.replaceWhitespace = prefs.getBoolPref("extensions.firebug.fireformat.preview.showWhitespace"); text.wrapPosition = prefs.getIntPref("extensions.firebug.fireformatCssFormatter.wrapSize"); text.tabSize = prefs.getIntPref("extensions.firebug.fireformatCssFormatter.tabSize"); text.value = formatter.format(preview); window.sizeToContent(); }, 0); };})();
|
this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) }
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
|
this.getQuerySet = function(queryJSON, callback) {
|
this._retrieveBytes = function(key, callback) { this._redisClient.get(key, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve BYTES for key', key, err) } callback((valueBytes ? valueBytes.toString() : "null")) }) } this._retrieveSet = function(key, callback) { this._redisClient.smembers(key, bind(this, function(err, membersBytes) { if (err) { throw logger.error('could not retrieve set members', key, err) } membersBytes = membersBytes || [] var members = [] for (var i=0, memberBytes; memberBytes = membersBytes[i]; i++) { members.push(memberBytes.toString()) } callback(members) })) } this.monitorQuery = function(queryJSON) {
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
})) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || [])
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
|
mutation = { id: newItemId, op: 'set', prop: propName, args: [value] }
|
key = shared.keys.getItemPropertyKey(newItemId, propName), mutation = { id: key, op: 'set', args: [value] }
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
'append': 'lpush'
|
'append': 'lpush', 'sadd': 'sadd', 'srem': 'srem'
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
var itemId = mutation.id, propName = mutation.prop,
|
var key = mutation.id, propName = shared.keys.getKeyInfo(key).property,
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
mutationBytes = connId.length + connId + JSON.stringify(mutation),
|
mutationBytes = connId.length + connId + JSON.stringify(mutation)
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
args.unshift(shared.keys.getItemPropertyKey(itemId, propName))
|
args.unshift(key)
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName)
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
|
this._redisClient.publish(itemPropChannel, mutationBytes)
|
this._redisClient.publish(key, mutationBytes)
|
exports = Class(Server, function(supr) { this.init = function(redis, connectionCtor) { supr(this, 'init', [connectionCtor]) this._redis = redis this._uniqueId = 0 this._redisClient = this._createRedisClient() // TODO For now we clear out all the query locks on every start up. // This is because if the query observer loses its connection to // the redis server before shut down, then it never gets the chance // to release the queries it is observing. I'm not sure what the correct // solution to the this problem is. this._redisClient.stream.addListener('connect', bind(this, function() { var locksPattern = shared.keys.getQueryLockPattern() this._redisClient.keys(locksPattern, bind(this, function(err, keysBytes) { if (err) { throw logger.error('Could not retrieve query lock keys on startup', err) } if (!keysBytes) { return } // This is really really ugly - keys are concatenated with commas. Split on ,L and then append // an L in front of every key. This will break if there is a query with the string ",L" in a key or value var keys = keysBytes.toString().substr(1).split(',L') logger.log("Clear out query lock keys", keys) for (var i=0, key; key = keys[i]; i++) { this._redisClient.del('L' + key, function(err) { if (err) { throw logger.error("Could not clear out key") } }) } })) })) } this._createRedisClient = function() { var client = this._redis.createClient() client.stream.setTimeout(0) // the stream is the redis client's net connection return client } var connectionId = 0 // TODO Each server will need a unique id as well to make each connection id globally unique this.buildProtocol = function() { return new this._protocolClass('c' + connectionId++, this._createRedisClient()); }/******************************* * Connection request handlers * *******************************/ this.getItemProperty = function(itemId, propName, callback) { var key = shared.keys.getItemPropertyKey(itemId, propName) this._redisClient.get(key, bind(this, function(err, valueBytes) { if (err) { throw logger.error('could not retrieve properties for item', key, err) } callback((valueBytes ? valueBytes.toString() : "null"), key) })) } this.getListItems = function(listKey, from, to, callback) { this._redisClient.lrange(listKey, from, to, bind(this, function(err, itemBytesArray) { if (err) { throw logger.error('could not retrieve list range', listKey, from, to, err) } if (!itemBytesArray) { callback([]) return } var items = map(itemBytesArray, function(itemBytes) { return itemBytes.toString() }) callback(items) })) } this.getQuerySet = function(queryJSON, callback) { var queryKey = shared.keys.getQueryKey(queryJSON), lockKey = shared.keys.getQueryLockKey(queryJSON) this._redisClient.get(lockKey, bind(this, function(err, queryIsHeld) { if (err) { throw logger.error('could not check for query lock', lockKey, err) } if (queryIsHeld) { return } logger.log('Publish request for query observer to monitor this query', queryJSON) this._redisClient.publish(shared.keys.queryRequestChannel, queryJSON) })) this._redisClient.smembers(queryKey, bind(this, function(err, members) { if (err) { throw logger.error('could not retrieve set members', queryKey, err) } callback(members || []) })) } this.createItem = function(itemProperties, origConnection, callback) { this._redisClient.incr(shared.keys.uniqueIdKey, bind(this, function(err, newItemId) { if (err) { throw logger.error('Could not increment unique item id counter', err) } var doCallback = blockCallback(bind(this, callback, newItemId)) for (var propName in itemProperties) { var value = JSON.stringify(itemProperties[propName]), mutation = { id: newItemId, op: 'set', prop: propName, args: [value] } this.mutateItem(mutation, origConnection, doCallback.addBlock()) } doCallback.tryNow() })) } this._operationMap = { 'set': 'set', 'append': 'lpush' } this.mutateItem = function(mutation, originConnection, callback) { var itemId = mutation.id, propName = mutation.prop, operation = this._operationMap[mutation.op], args = Array.prototype.slice.call(mutation.args, 0) connId = originConnection.getId(), mutationBytes = connId.length + connId + JSON.stringify(mutation), args.unshift(shared.keys.getItemPropertyKey(itemId, propName)) logger.log('Apply and publish mutation', operation, args) if (callback) { args.push(callback) } this._redisClient[operation].apply(this._redisClient, args) // TODO clients should subscribe against pattern channels, // e.g. for item props *:1@type:* and for prop channels *:#type:* // mutations then come with a single publication channel, // e.g. :1@type:#type: for a mutation that changes the type of item 1 var itemPropChannel = shared.keys.getItemPropertyChannel(itemId, propName) var propChannel = shared.keys.getPropertyChannel(propName) this._redisClient.publish(itemPropChannel, mutationBytes) this._redisClient.publish(propChannel, mutationBytes) }})
|
this._panelWidth = 500;
|
this._panelWidth = 400;
|
exports = Singleton(browser.UIComponent, function(supr) { this.createContent = function() { this.addClassName('PanelManager'); this._focusIndex = 0; this._offset = 0; this._panelsByItem = {}; this._panelsByIndex = []; this._panelWidth = 500; this._panelMargin = 30; this._offset = 0; this._panelAnimation = new browser.Animation(bind(this, '_animatePanels'), 1000); this._scrollAnimation = new browser.Animation(bind(this, '_animateScroll'), 500); events.add(this._element, 'scroll', bind(this, '_onScroll')); } this._onScroll = function() { browser.itemFocus.layout(); } this.showItem = function(item) { if (this._panelsByItem[item]) { this.focusPanel(this._panelsByItem[item]); } else { this._blurFocusedPanel(); this._addPanel(item); this.focusPanel(this._panelsByIndex[this._focusIndex]); } } this.focus = function() { this.focusPanel(this._panelsByIndex[this._focusIndex]); } this.focusPanel = function(panel) { if (!panel) { return; } this._blurFocusedPanel(); this._focusIndex = this._getPanelIndex(panel); panel.focus(); var panelElement = panel.getElement(); this._currentScroll = this._element.scrollLeft; if (panelElement.offsetLeft - this._offset < this._currentScroll) { // scroll left by panel's width, or all the way to panel if way off screen this._targetScroll = Math.min(this._currentScroll - panelElement.offsetWidth, panelElement.offsetLeft - this._offset); this._scrollAnimation.animate(); } else if (panelElement.offsetLeft + panelElement.offsetWidth > this._currentScroll + this._element.offsetWidth) { // scroll right by panel's width, or all the way to panel if way off screen this._targetScroll = Math.max(this._currentScroll + panelElement.offsetWidth, panelElement.offsetLeft - (this._element.offsetWidth - panelElement.offsetWidth) + 40); this._scrollAnimation.animate(); } } this._animateScroll = function(n) { var diff = this._currentScroll - this._targetScroll; this._element.scrollLeft = this._currentScroll - diff * n; } this._blurFocusedPanel = function() { if (!this._panelsByIndex[this._focusIndex]) { return; } this._panelsByIndex[this._focusIndex].blur(); } this.focusPanelIndex = function(index) { if (!this._panelsByIndex[index]) { return; } this.focusPanel(this._panelsByIndex[index]); } this.focusLastPanel = function() { this.focusPanelIndex(this._panelsByIndex.length - 1); } this.focusNextPanel = function() { var nextIndex = this._focusIndex + 1 if (nextIndex == this._panelsByIndex.length) { nextIndex = 0; } this.focusPanel(this._panelsByIndex[nextIndex]); } this.focusPreviousPanel = function() { var previousIndex = this._focusIndex - 1; if (previousIndex < 0) { previousIndex = this._panelsByIndex.length - 1 } this.focusPanel(this._panelsByIndex[previousIndex]); } this.hasPanels = function() { return !!this._panelsByIndex.length; } this.removePanel = function(panel) { var panelIndex = this._getPanelIndex(panel); this._panelsByIndex.splice(panelIndex, 1); delete this._panelsByItem[panel.getItem()]; dom.remove(panel.getElement()); if (panelIndex == this._focusIndex) { // panelIndex will now refer to panel on the right of removed panel if (panelIndex >= this._panelsByIndex.length) { panelIndex -= 1; } this.focusPanel(this._panelsByIndex[panelIndex]); } this._positionPanels(); } this.setOffset = function(offset) { this._offset = offset; } this.layout = function(size) { dom.setStyle(this._element, size); for (var i = 0, panel; panel = this._panelsByIndex[i]; i++) { panel.layout({ height: this._element.offsetHeight - 50 }); } } this._getPanelIndex = function(panel) { for (var i=0; i < this._panelsByIndex.length; i++) { if (panel != this._panelsByIndex[i]) { continue; } return i; } } this._addPanel = function(item) { if (this._panelsByItem[item]) { return this._panelsByItem[item]; } var panel = new browser.panels.ItemPanel(this, item); panel.isNew = true; this._panelsByIndex.splice(this._focusIndex, 0, panel); this._panelsByItem[item] = panel; this._positionPanels(); } this._positionPanels = function() { if (!this._panelsByIndex.length) { return; } var targetOffset = this._offset; for (var i = 0, panel; panel = this._panelsByIndex[i]; i++) { panel.prependTo(this._element); if (panel.isNew) { panel.currentOffset = targetOffset; } else { panel.getElement().offsetLeft - this._element.offsetLeft } panel.currentOffset = panel.isNew ? targetOffset : panel.getElement().offsetLeft - this._element.offsetLeft; delete panel.isNew; panel.targetOffset = targetOffset; panel.layout({ width: this._panelWidth, height: this._element.offsetHeight - 50 }); targetOffset += this._panelWidth + this._panelMargin; } this._panelAnimation.animate(); } this._animatePanels = function(n) { for (var i=0, panel; panel = this._panelsByIndex[i]; i++) { var diff = panel.targetOffset - panel.currentOffset; panel.layout({ left: panel.currentOffset + (diff * n) }); } }})
|
container.addEventListener("transitionend", function() { self.alertTransitionOver(); }, true);
|
Browser.tabs.forEach(function(aTab) { if (aTab.browser.getAttribute("remote") == "true") aTab.resurrect(); })
|
container.addEventListener("transitionend", function() { self.alertTransitionOver(); }, true);
|
YAHOO.util.Assert.areEqual(initialFlavorValue, ORBEON.xforms.Controls.getCurrentValue(flavorSelect1)); });
|
YAHOO.util.Assert.isTrue(inputField.disabled, "input field still disabled when non-relevant"); ORBEON.util.Test.executeCausingAjaxRequest(this, function() { ORBEON.xforms.Document.setValue("relevant", "true"); }, function() { YAHOO.util.Assert.isTrue(inputField.disabled, "input field still disabled when becomes relevant because readonly"); }); });
|
}, function() { // Check that the values didn't change YAHOO.util.Assert.areEqual(initialFlavorValue, ORBEON.xforms.Controls.getCurrentValue(flavorSelect1)); });
|
ok.click(function() { box.hide(); var resp = (type == 'prompt')?input.val():true; if(callback) callback(resp); }).focus();
|
store.add(result.rows.map(function(row){ return new R(row); }));
|
ok.click(function() { box.hide(); var resp = (type == 'prompt')?input.val():true; if(callback) callback(resp); }).focus();
|
thiss.openAccordionCase(thiss, '_314466', function() { var table = YAHOO.util.Dom.get('my-accordion$_314466-table$_314466-table-table'); var container = table.parentNode.parentNode; YAHOO.util.Assert.isFalse(YAHOO.util.Dom.hasClass(container, 'fr-dt-initialized'), "The datatable shouldn't be initialized at that point"); ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() { YAHOO.util.UserAction.click(YAHOO.util.Dom.get('my-accordion$show-314466'), {clientX: 1}); }, function() { thiss.wait(function() { table = YAHOO.util.Dom.get('my-accordion$_314466-table$_314466-table-table'); var container = table.parentNode.parentNode; YAHOO.util.Assert.isTrue(YAHOO.util.Dom.hasClass(container, 'fr-dt-initialized'), "The datatable should be initialized at that point"); YAHOO.util.UserAction.click(YAHOO.util.Dom.get('my-accordion$hide-314466'), {clientX: 1}); thiss.closeAccordionCase(thiss, '_314466') }, 200);
|
thiss.openAccordionCase(thiss, 'optional-scrollh', function() { var tbody = YAHOO.util.Dom.get('my-accordion$optional-scrollh-table$optional-scrollh-table-tbody'); var bodyContainer = tbody.parentNode.parentNode; thiss.checkHorizontalScrollbar(bodyContainer, false); thiss.closeAccordionCase(thiss, 'optional-scrollh');
|
thiss.openAccordionCase(thiss, '_314466', function() { var table = YAHOO.util.Dom.get('my-accordion$_314466-table$_314466-table-table'); var container = table.parentNode.parentNode; YAHOO.util.Assert.isFalse(YAHOO.util.Dom.hasClass(container, 'fr-dt-initialized'), "The datatable shouldn't be initialized at that point"); ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() { YAHOO.util.UserAction.click(YAHOO.util.Dom.get('my-accordion$show-314466'), {clientX: 1}); }, function() { thiss.wait(function() { table = YAHOO.util.Dom.get('my-accordion$_314466-table$_314466-table-table'); var container = table.parentNode.parentNode; YAHOO.util.Assert.isTrue(YAHOO.util.Dom.hasClass(container, 'fr-dt-initialized'), "The datatable should be initialized at that point"); YAHOO.util.UserAction.click(YAHOO.util.Dom.get('my-accordion$hide-314466'), {clientX: 1}); thiss.closeAccordionCase(thiss, '_314466') }, 200); }); });
|
});
|
thiss.openAccordionCase(thiss, '_314466', function() { var table = YAHOO.util.Dom.get('my-accordion$_314466-table$_314466-table-table'); var container = table.parentNode.parentNode; YAHOO.util.Assert.isFalse(YAHOO.util.Dom.hasClass(container, 'fr-dt-initialized'), "The datatable shouldn't be initialized at that point"); ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() { YAHOO.util.UserAction.click(YAHOO.util.Dom.get('my-accordion$show-314466'), {clientX: 1}); }, function() { thiss.wait(function() { table = YAHOO.util.Dom.get('my-accordion$_314466-table$_314466-table-table'); var container = table.parentNode.parentNode; YAHOO.util.Assert.isTrue(YAHOO.util.Dom.hasClass(container, 'fr-dt-initialized'), "The datatable should be initialized at that point"); YAHOO.util.UserAction.click(YAHOO.util.Dom.get('my-accordion$hide-314466'), {clientX: 1}); thiss.closeAccordionCase(thiss, '_314466') }, 200); }); });
|
|
y1Input.change( function() {
|
x2Input.change( function() {
|
y1Input.change( function() { if (isNaN(parseFloat(this.value)) || this.value < 0.0 || this.value > 1.0) { this.value = 0.0; } $this.paint.linearGradient.setAttribute('y1', this.value); beginStop.setAttribute('y', MARGINY + SIZEY*this.value - STOP_RADIUS); });
|
this.value = 0.0;
|
this.value = 1.0;
|
y1Input.change( function() { if (isNaN(parseFloat(this.value)) || this.value < 0.0 || this.value > 1.0) { this.value = 0.0; } $this.paint.linearGradient.setAttribute('y1', this.value); beginStop.setAttribute('y', MARGINY + SIZEY*this.value - STOP_RADIUS); });
|
$this.paint.linearGradient.setAttribute('y1', this.value); beginStop.setAttribute('y', MARGINY + SIZEY*this.value - STOP_RADIUS);
|
$this.paint.linearGradient.setAttribute('x2', this.value); endStop.setAttribute('x', MARGINX + SIZEX*this.value - STOP_RADIUS);
|
y1Input.change( function() { if (isNaN(parseFloat(this.value)) || this.value < 0.0 || this.value > 1.0) { this.value = 0.0; } $this.paint.linearGradient.setAttribute('y1', this.value); beginStop.setAttribute('y', MARGINY + SIZEY*this.value - STOP_RADIUS); });
|
JX[name].listen = function(type, callback) { if (__DEV__) { if (!(type in this.__events__)) { throw new Error( this.__readable__+'.listen("'+type+'", ...): '+ 'invalid event type. Valid event types are: '+ JX.keys(this.__events__).join(', ')+'.'); } } return JX['Stratcom'].listen( 'obj:'+type, this.__name__, JX.bind(this, function(e) {
|
JX.bind(this, function(e) {
|
JX[name].listen = function(type, callback) { if (__DEV__) { if (!(type in this.__events__)) { throw new Error( this.__readable__+'.listen("'+type+'", ...): '+ 'invalid event type. Valid event types are: '+ JX.keys(this.__events__).join(', ')+'.'); } } return JX['Stratcom'].listen( 'obj:'+type, this.__name__, JX.bind(this, function(e) { return callback.apply(this, e.getData().args); })); };
|
};
|
JX[name].listen = function(type, callback) { if (__DEV__) { if (!(type in this.__events__)) { throw new Error( this.__readable__+'.listen("'+type+'", ...): '+ 'invalid event type. Valid event types are: '+ JX.keys(this.__events__).join(', ')+'.'); } } return JX['Stratcom'].listen( 'obj:'+type, this.__name__, JX.bind(this, function(e) { return callback.apply(this, e.getData().args); })); };
|
|
expression.constant = node_list.evaluate( context ); return expression.resolve(context);
|
return context.get(first) == context.get(second) ? node_list.evaluate(context) : '';
|
return function (context) { expression.constant = node_list.evaluate( context ); return expression.resolve(context); };
|
}, function() { });
|
OT.executeCausingAjaxRequest(this, function() { OD.getElementByTagName(OD.get("focus-non-relevant-no-error"), "input").focus(); }, function() {
|
}, function() { // nop });
|
0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
|
function (s) { return s["clickable"] != false; });
|
0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
|
YAHOO.util.Assert.isTrue(inputField.disabled, "input field still disabled when non-relevant");
|
}, function() { YAHOO.util.Assert.isTrue(inputField.disabled, "input field still disabled when non-relevant"); ORBEON.util.Test.executeCausingAjaxRequest(this, function() { ORBEON.xforms.Document.setValue("relevant", "true"); }, function() { YAHOO.util.Assert.isTrue(inputField.disabled, "input field still disabled when becomes relevant because readonly"); }); });
|
|
this.server.createItem(request.data, this, bind(this, function(itemData) { var response = { _requestId: request._requestId, data: itemData }
|
this.handleRequest('FIN_REQUEST_EXTEND_LIST', bind(this, function(request) { var key = request.key, from = request.from, to = request.to this.server.getListItems(key, from, to, bind(this, function(items) { var response = { _requestId: request._requestId, data: items }
|
this.server.createItem(request.data, this, bind(this, function(itemData) { var response = { _requestId: request._requestId, data: itemData } this.sendFrame('FIN_RESPONSE', response) }))
|
}))
|
this.server.createItem(request.data, this, bind(this, function(itemData) { var response = { _requestId: request._requestId, data: itemData } this.sendFrame('FIN_RESPONSE', response) }))
|
|
this.handleRequest('FIN_REQUEST_ADD_REDUCTION', bind(this, function(args) { var itemSetId = args.id, reductionId = args.reductionId this.server.addItemSetReduction(itemSetId, reductionId, this._itemSetSubs[itemSetId])
|
this.handleRequest('FIN_REQUEST_MUTATE_ITEM', bind(this, function(mutation){ if (typeof this._authenticatedUser == 'string') { mutation._user = this._authenticatedUser } this.server.mutateItem(mutation, this._id)
|
this.handleRequest('FIN_REQUEST_ADD_REDUCTION', bind(this, function(args) { var itemSetId = args.id, reductionId = args.reductionId this.server.addItemSetReduction(itemSetId, reductionId, this._itemSetSubs[itemSetId]) }))
|
ORBEON.xforms.Offline.loadFormInIframe(url, function(offlineIframe) {
|
var formLoadingIntervalID = window.setInterval(function() { if (formLoadingComplete) { window.clearInterval(formLoadingIntervalID); ORBEON.xforms.Offline.loadFormInIframe(url, function(offlineIframe) {
|
ORBEON.xforms.Offline.loadFormInIframe(url, function(offlineIframe) { // Wait for the form to be marked as offline before we call the listener var takingFormOfflineIntervalID = window.setInterval(function() { if (! offlineIframe.contentWindow.ORBEON.xforms.Offline.isOnline) { window.clearInterval(takingFormOfflineIntervalID); // Calling listener to notify that the form is now completely offline if (formOfflineListener) formOfflineListener(offlineIframe.contentWindow); } }, 100); // Send offline event to the server offlineIframe.contentWindow.ORBEON.xforms.Document.dispatchEvent("#document", "xxforms-offline"); });
|
} }, 100);
|
ORBEON.xforms.Offline.loadFormInIframe(url, function(offlineIframe) { // Wait for the form to be marked as offline before we call the listener var takingFormOfflineIntervalID = window.setInterval(function() { if (! offlineIframe.contentWindow.ORBEON.xforms.Offline.isOnline) { window.clearInterval(takingFormOfflineIntervalID); // Calling listener to notify that the form is now completely offline if (formOfflineListener) formOfflineListener(offlineIframe.contentWindow); } }, 100); // Send offline event to the server offlineIframe.contentWindow.ORBEON.xforms.Document.dispatchEvent("#document", "xxforms-offline"); });
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.